Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unit testing with JUnit

Similar presentations


Presentation on theme: "Unit testing with JUnit"— Presentation transcript:

1 Unit testing with JUnit
CSE 403

2 Outline Unit testing vs. main() testing Unit test demo Fixture demo

3 Resources Test Infected: Programmers Love Writing Tests JUnit Cookbook
“Testing with JUnit” chapter from “Java Development with Ant” Testing: Cactus and JUnit chapter from “Jakarta Pitfalls” And more (see Useful Resources)

4 Unit testing Alternative to testing in main()
Explicit concept of test pass/fail Geared towards testing public interface Mechanism for collecting results in structured fashion Replicability "code a little, test a little, code a little, test a little"

5 A unit test Tests that code accurately reflects one intention Demo

6 Multiple unit tests Set of objects tested is a fixture
To test with the same fixture: Extend TestCase Create instance variable for each part of fixture Override setUp(), tearDown() Demo

7 Good practices Test first
Improve existing test cases to reflect newly found bugs Give asserts good names Avoid side effects in test cases


Download ppt "Unit testing with JUnit"

Similar presentations


Ads by Google