Previous Next vertical dots separating previous/next from contents/index/pdf

Step 3: Run the Test Case

In this step you'll run the test against the control class.

In this step, you will:

Run a Successful Test

  1. In the Project Explorer, right-click EmployeeControlTestCase and select Run As > JUnit Test.

    The JUnit view will appear with the green progress bar, meaning that all tests have passed.

Run a Failed Test

  1. Edit the testGetManagerNames method so that the expected array length is 2 instead of 3 and run the test again.

    The JUnit view will look like the following. The red bar indicates that the test has failed and an error message is shown.

Notice that at no time during this test was a server started, the test was running in a pure JUnit environment. The only special class used was a standard sub-class of TestCase. (This is not universally true for all controls. In cases where the control takes a dependency on a server-bound resource, the control cannot be thoroughly tested in a pure JUnit environment.)

Also, notice that the setup of the test case was very straight forward. Most of the setup was in making sure the test class lived in its own source folder. By extending ControlTestCase and letting the JUnit wizard generate the stub methods, all you had to do was write your test code.

Related Topics

Testing Controls

Click one of the following arrows to navigate through the tutorial:


Skip navigation bar   Back to Top