intro to junit: outline_ja

1. itroduction
1.1 what is Junit
keywords: java unit test, framework

1.2 benefits of using Junit
1.2.1 Junit tests allow you to write code faster while increasing quality.
when you write tests using JUnit, youll spend less time debugging, and youll have confidence that changes to your code actually work.
without test, its easy to become paranoid about refactoring or adding new features because you dont know what might break as a result.
1.2.2 JUnit is elegantly simple
should be simple, otherwise theres no incentive to start writing tests in the first place.
1.2.3 Junit tests check their own results and provide immediate feedback.
1.2.4 JUnit tests can be composed into a hierarchy of test suites.
1.2.5 writing Junit tests is inexpensive
1.2.6 junit tests increase the stability of software.
1.2.7 junit tests are developer tests
unlike functional tests, which treat the system as a black box and ensure that the software works as a whole, unit tests are written to test the fundamental building blocks of the system from the inside out.
1.2.8 JUnit tests are written in java
1.2.9 JUnit is free!

2. body
2.1 design of Junit
Junit is designed around two key design patterns: the command pattern and the composite pattern.

atestcase is a command object. any class that contains test methods should subclass the testcase class. a testcase can define any number of public testXXX() methods. when you want to check the expected and actual test results, you invoke a variation of the assert() method.

testcase subclasses that contain multiple testXXX89 mmethods can use the setUp() and tearDown() methods to initialize and release any common objects under test, referred to as the test fixture. each test runs in the context of its own ficture, calling setUp() before and tearDown() agter each test method to ensure there can be no side effects among test runs.

testcase instances can be composed into testsuite hierarchies that automatically invole all the testXXX() methods defined in each testcase instance. a testsuite is a composite of other tests, either testcase instances or other testsuite instances. the composite behavior exhibited by the testsuite allows you assemble test suites of test suites of tests, to an arbitrary depth, and run all the tests automatically and uniformaly to yield a single pass or fail status.

by creating a testsuite in each java package, at various levels of packaging, you can run a testsuite at any level of abstraction.

keep the following things in mind when writing JUnit tests:
*the software does well those things that the tests check.
*thest a little, code a little, test a little, code a little...
*make sure all tests always run at 100%.
run all the all tests in the system at least once per day.
write tests for the areas of code with the highest probablility of breakage.

2007-04-22 15:14 : __fw__junit : コメント : 0 : トラックバック : 0 :

« next  ホーム  prev »




tag cloud

category cloud