Java Reference
In-Depth Information
Figure 7.5 The Statistics tabs can show you how much memory was consumed by each test as well
as how long it took to run each one.
Running tests with other test runners
The test runner built into IDEA is powerful and flexible. However, if you're nos-
talgic, you can use the classic test runners included with the JU nit framework.
(Note, however, that you'll lose many of IDEA 's JU nit integration features.) To do
so, add a main() method, as shown in the following code, and run the class as a
normal Run/Debug configuration target instead of a JU nit configuration:
public static void main(String[] args) {
TestRunner testRunner = TestRunner();
testRunner.run(StringUtilsTest.class);
}
Two test runners are included with the standard JU nit distribution: one in the
junit.swingui package that creates a graphical interface, and another, text-only
version in junit.textui . Import the appropriate version into your code. You can
also use this technique to run other, third-party test runners if you wish.
The text-only version runs your JU nit tests in a standard IDEA Run window. A
simple test summary report is shown in figure 7.6, along with a list of failures and
their accompanying stack traces. Any errors are hot-linked back to the source of
the failure inside your test case. In this example, you can see that a failure
occurred inside the testFixedRate() method. Any output produced by the test
cases is also displayed in this window, as are your assert failure messages.
The graphical test runner, shown in figure 7.7, is a little fancier than the text
version, providing an alternate view of your test execution results. As shown, you
 
 
 
 
 
 
Search WWH ::




Custom Search