140 likes | 152 Views
Testing with JUnit. http://flic.kr/p/7iffKj. Iterative Development Process. Analysis. Requirements. Design. Initial Planning. Implementation. Planning. Testing. Evaluation. Deployment. We are here. Definitions. Defect / Bug / Fault : Thing that developer did wrong
E N D
Testing with JUnit http://flic.kr/p/7iffKj
Iterative Development Process Analysis Requirements Design InitialPlanning Implementation Planning Testing Evaluation Deployment We are here
Definitions • Defect/Bug/Fault: Thing that developer did wrong • Cause of program’s incorrect behavior • Error: Incorrect behavior of program • May not be observable to user • Failure: User-observable error; loss of functionality Some authors prefer to flip the above defs of fault and error
More Definitions • Test/Test Case: One execution of program that may expose bug • Test Suite: Set of test cases • Often used to group related tests
Decisions when designing tests • What subset of system to test? • How to choose test cases?
What subset of system to test? smaller subset Unit testing: Test modules in isolation; smallest “units” of code Integration testing: Test groups of collaborating units System testing: Test the complete system larger subset
Unit versus Integration Testing • Problem: Distinction is fuzzy because depends on definition of “unit”, which varies (class? method?...) • Some additional distinctions:
Decisions when designing tests • What subset of system to test? • How to choose test cases?
How to choose test cases? • Blackbox testing: Choose based on module’s possible inputs and outputs • Do not use code • Often test boundary cases • Whitebox testing: Uses internal logic to choose tests • Different levels of code coverage • Aka glass box testing, clear box testing • Regression testing: Keep tests that reveal old bugs • Rationale: “Fixed” bugs come back!
Many higher-level testing strategies as well • Acceptance testing: Users test to see if system meets actual use requirements • Serves both validation and verification • Usability testing: Observe users using system with eye on usability of system • Test-driven development: … more next chapter … • And many more…
Eclipse + JUnit demo time! http://flic.kr/p/5dfuqL
JUnit Annotation Reference From http://www.vogella.com/articles/JUnit/article.html
JUnit Method Reference From http://www.vogella.com/articles/JUnit/article.html
JUnit Tips • If target of unit test is edu.memphis.Foo, then make test edu.memphis.test.FooTest • You can use JUnit for unit and integration tests