JUnit is a test framework that can be used to incrementally build a test suite for unit testing code. It allows you to use iterative development, coding and testing as you go, with immediate feedback on how well the code is working. JUnit defines how to structure your test cases and provides the tools to run them.
You can use JUnit to run single tests or test suites. Single tests can be run in two different ways: static or dynamic. The dynamic method is more compact, the static method is safer. The choice of method depends on your needs. For more information, see “JUnit Test Infected: Programmers Love Writing Tests”.
To set up a test case in JUnit, you create a test case class, implement a subclass of the test case class and add a JUnit test method, which is just an ordinary method without parameters that creates the objects that the test will interact with, (commonly referred to as a test's fixture), exercises the objects in the fixture, and verifies the result.
To create a test suite you use a common fixture to run your test cases. Each test runs in its own fixture according to your definitions of how to run individual test cases and test suites. JUnit calls setUp and tearDown for each test so that there can be no side effects among test runs.
You can launch JUnit from Weblogic Workshop in different ways, use it for unit testing page flows, object models, web services, EJBs, JCS and JCX components. You can also use JUnit, Workshop and Cactus together. The following sections go into depth on these subjects.
Some components are internally testable components and others are externally testable components. Externally testable components are those components that can be invoked from outside the J2EE container, typically through HTTP. When writing tests, your test case can initiate a network connection to the server, send it the appropriate request, and verify that the server’s response is correct.