
55ca95e9544a38277820ce831ca8affc.ppt
- Количество слайдов: 13
Preventing Bugs with Unit Testing Chapter 5 - Coder to Developer by Mike Gunderloy Instructor : Dr. James Fawcett Presented by Priyaa Nachimuthu priyaa@syr. edu
Agenda n Types of Testing n Testing for Developers n Unit Testing n Using NUnit n Test – Driven Development n Refactoring n Unit Testing Summary
Types of Testing n Unit Testing – testing very small pieces of code n Integration Testing - code doesn't break someone else’s code n System Testing – exercising the entire application to make it fail n Stress Testing – push the limits of the application until it fails n Beta Testing – giving copies of the unfinished code to outside testers for feedback n Acceptance Testing – formal verification of requirements
Testing for Developers n Check out the module n Write the code for the next feature to be implemented n Write unit tests to test the feature n Ensure that the code passes the unit tests n Get the latest code for the entire application n Make sure the whole project passes the integration tests n Check in code and unit tests
Unit Testing n JUnit – by Erich Gamma and Kent Beck for Java development n NUnit – free, open source framework, a. Net unit testing tool. NUnit. Addin, Test. Runner for NUnit integrates NUnit with VS. Net. NUnit. Asp supports NUnit testing of ASP. Net pages. ( http: //nunit. org ) n cs. Unit – free, open-source implementation. Additional features, includes project wizards to build new testing projects easily and a UI with more information. ( http: //csunit. org ) n Harness. It - $199. Pluaggable test engine architecture. Easy testing of web and remote applications using the same tools as local windows applications. ( www. unittesting. com/default. aspx ) n X-Unity - $129. VS. Net integration, a development kit for unit tests, and integration ( http: //x-unity. miik. com. ua/ ) n . TEST - $900. Writes many unit tests for the user. Uses rules-based engine to ensure code correctness and allows the user to write custom tests. ( www. parasoft. com/jsp/products/home. jsp? product=Test. Net )
Using NUnit for Unit Testing n A simple test n Debugging NUnit tests n Testing an exception n Testing with mock objects
Test Driven Development n A new testing technique by advocates of Extreme Programming. n Introduction to TDD : “Test-Driven Development” by Kent Beck. n Two simple rules - Write a failing automated test before writing any code - Remove duplication
TDD – Plan of Action n Quickly add a test n Run all tests and see the new one fail n Make a little change n Run all tests and see them all succeed n Refactor to remove duplication
TDD in Action n Code Sample
Refactoring n Martin Fowler’s Refactoring : Improving the Design of the existing Code n The process of changing a software system in such a way that it doesn't alter the external behavior of the code yet improves its internal structure. n Refactoring patterns n Code Thrashing – developers with different ideas
Refactoring Tools n dot. Easy – free ( www. doteasy. com. uy/ ) n The C# Refactoring Tool - $110 ( http: //dotnetrefactoring. com/ ) n C# Refactory - $99 ( www. xtreme- simplicity. net/CSharp. Re. Factory. html ) n Fly. Wheel - $449 ( www. velocitis. com/ )
Unit Testing Checklist n Write unit tests for all code n Don’t postpone the tests n Ensure that the code passes unit tests and integration tests before check-ins n Use automated tools such as NUnit n Check the tests and any other setup files into SCC n Consider using TDD for 100% coverage n Refactor code only when there are thorough set of tests for the code
Thank you!
55ca95e9544a38277820ce831ca8affc.ppt