Creating a JUnit Test for a Business Components Project
A JUnit business components test application is similar to a generic Java test, and consists
of the following components:
- One or more test cases, which invoke the methods that are to be tested,
and make assertions about the expected results. Business components test cases
are concerned with testing view objects' data validation, traversal, and updating.
Wizard-generated test case classes have 'Test'
in their names.
- A test fixture, which provide the state in which the tests are run. Business
components test fixtures access view objects from an application module. Wizard-generated
test fixture classes have 'Fixture' in their
names.
- A test suite, which invokes the test cases. Wizard-generated test suite
classes have 'AllTests' in their names.
- A runner, which invokes the test suite and collates and displays the results
of the tests.
To create a JUnit test for a business components project:
- Create a business component
project.
- Create your test classes:
- In the Navigator, select the project.
- Choose File | New to open
the New Gallery.
- In the Categories tree, expand General
and select Unit Tests (JUnit).
- In the Items list, select one of
the business components wizards:
- Select Business Components Test Suite
to create an entire test consisting of test suite, test fixture and
test case classes.
- Select Business Components Test Fixture
to create only test suite and test fixture classes. If you use this
wizard you must create your own test case classes.
- Click OK to invoke the wizard, and follow
its instructions to create the test classes. For more information at any
time, press F1 or click Help from within
the dialog.
- Edit the testAccess() methods of the test
case classes to perform the desired tests.
- If desired, create additional test cases,
and add them to the test suite.
- Build the project:
- In the Navigator, right-click the project.
- Choose Build Project.
Related topics
Unit Testing with JUnit
Creating a JUnit Test for a Generic Java
Project
Creating a JUnit Test Case
Running a JUnit Test