Java Reference
In-Depth Information
view of passed test cases on or off at any time. If a test case or suite contained no
failing tests, it's hidden as well.
Navigating through the failed tests
Doubtless you'll encounter failed tests. Using the Previous and Next Failure
arrows (or Ctrl+Alt+Up and Ctrl+Alt+Down , respectively) you can easily navi-
gate through these failures. Each time you move forward or backward through
the list, the next failed test is selected in the test tree. To automatically select the
first failure upon completion of your tests, enable the Select First Failed Test
option from the JU nit window's toolbar. You may also determine your starting
point by clicking any test in the tree.
Reviewing test cases
In order to learn why a test failed, you need to understand the steps it was taking
by reviewing the source code behind it. Double-clicking any test case in the tree
(failed or not) takes you straight to that test's source code in the editor window. By
backtracking into the source code behind the test as you review the test output
messages, you should be able to spot the problem.
Don't overlook the possibility that your bug might be in the test itself,
rather than in the code you're testing!
TIP
Similarly, you can right-click a test in the tree and select either the Jump to
Source (F4) or Show Source (Ctrl+Enter) option to review the test's source code.
The difference between the two options is that Jump to Source moves your focus
to the editor window, while Show Source leaves you in the JU nit window. You can
also use the Autoscroll to Source toolbar button to keep the source window
matching the current selection in the JU nit tool window.
Rerunning failed tests
You also have the option of running an individual test again by right-clicking its
entry in the test tree and selecting the appropriate run option. Suites and test
cases can also be run this way and will execute all the tests below them as well. If
you run a test in this manner, it clears the current set of results unless you've
locked down the results tab by right-clicking it and selecting the Pin Tab option.
Unfortunately, you're limited to running individual tests, test cases, or suites.
It isn't possible to run ad hoc collections of tests (for example, all the failing tests)
without manually defining a test suite using the JU nit API .
 
 
 
 
 
 
 
Search WWH ::




Custom Search