IntelliJ IDEA 2021.3 Help

Explore test results

After IntelliJ IDEA finishes running your tests, it shows the results in the Run tool window on the Test Runner tab.

The console on the right shows the output of the current test session. It allows you to see the detailed information on the test execution and why your tests failed or were ignored.

The Test Runner toolbar located above the list of test results allows you to show and hide successful and ignored tests, display how much time it took to run each test, export, import, and sort test results.

Test results shown on the Test Runner tab of the Run tool window

the Test Runner toolbar

Next to each test on the Test Runner tab, the IDE displays an icon that marks the test status:

Icon

Description

Test error

Test error. This status is assigned to tests that caused an exception from the tested source code.

Test failed

Test failed. If at least one child test fails, all its parent tests are marked as failed.

Test ignored

Test ignored.

Test in progress

Test in progress.

Test passed

Test passed successfully.

Terminated

Test terminated. This status is assigned to tests that were stopped.

If at least one test receives this status, then all unfinished tests and their parent tests are marked as terminated.

Sort and filter test results

Use the following options on the Test Runner toolbar if you want to focus only on the failed tests or if you want to reorganize test results:

  • Disable the the Show Passed button Show Passed option to hide successful tests.

  • Disable the the Show Ignored button Show Ignored option to hide ignored tests.

  • Click the Sort Alphabetically button to sort test results alphabetically.

  • Click the Sort by Duration button to sort test results by duration.

Track test execution

In IntelliJ IDEA, you can monitor execution of the current test. If a test suite contains multiple tests, the list of tests expands to show test methods as they run one by one.

  • To monitor test execution, click  the Settings button on the Test Runner toolbar and enable the Track Running Test option.

    Track Running Test enabled
    Track Running Test disabled

Manage test results

  • Click the Settings button on the Test Runner toolbar and enable the following options:

    Options for managing test results
    • Track Running Test: monitor execution of the current test.

    • Show Inline Statistics: view the execution time for tests.

    • Suites Always on Top: always place test nodes on top of the list when you apply sorting.

    • Scroll to Stack Trace: if a test produced a lot of output (for example, logging) before failing, this option automatically scrolls the output console to the assertion failure once you select the test on the Test Runner tab.

    • Open Source at Exception: if you double-click a failed test method on the Test Runner tab with this option on, the editor will scroll to the line on which the exception was thrown (instead of scrolling to the test method declaration).

    • Navigate with Single Click: open the code for the selected test automatically in the editor.

    • Select First Failed Test When Finished: automatically select the first failed test in the list upon completing the test session.

    • Include Non-Started Tests into Rerun Failed: if some tests were ignored or not started during the previous test run, this option executes them together with the failed tests when you click Rerun Failed Tests button (Rerun Failed Tests).

View statistics

  • To view the execution time for tests, click the Settings button on the Test Runner toolbar and enable the Show Inline Statistics option.

    Test statistics shown on the Test Runner Tab

Jump to test declaration

  • Select the necessary test from the list on the Test Runner tab and press F4.

View assertEquals difference

If a unit test contains string assertEquals failures, the IDE enables you to compare the strings and view the differences.

  • Right-click the necessary test and select View assertEquals Difference from the context menu. You will be able to compare strings in the dedicated Differences viewer.

    Viewing assertEquals difference

View results of previous tests

IntelliJ IDEA automatically saves results of the last 10 tests. To open the list of recent tests:

  • Press Ctrl+Shift+; or click the Test History icon on the Test Runner toolbar and select the necessary test from the list.

    For each test, the list displays the run configuration name and a time stamp:

    Viewing results of previous tests

    You can also export test results to a file if you want to keep them or share with your team.

Export and import test results

Export test results to a file

  1. Click Export Test Results on the Test Runner toolbar.

    Using the Test Runner toolbar to export test results
  2. Select the format in which you want to save the file: HTML, XML (use this format if you want to import this file later to IntelliJ IDEA), or Custom, apply XSL template (click Browse button next to this option and select the *.xsl code style definition file).

  3. Specify the name of the output file and its location.

  4. If you want to open the file in your browser after you export it, select the Open exported file in browser checkbox. Click OK.

    Exporting test results to a file

Import test results

  1. To load a previously exported file, click Import Tests from File on the Test Runner toolbar.

    Importing test results
  2. In the dialog that opens, select the .xml file with test results and click Open.

Last modified: 01 August 2022