Explore test results
CLion shows test results in the Test Runner tab of the Run tool window:
The console on the right shows the output of the current test session.
Next to each test on the Test Runner tab, the IDE shows the test status icon:
Icon | Description |
---|---|
Test error. This status is assigned to tests that caused an exception from the tested source code. | |
Test failed. If at least one child test fails, all its parent tests are marked as failed. | |
Test ignored. | |
Test in progress. | |
Test passed successfully. | |
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. |
The Test Runner toolbar on the top allows you to sort and filter test results, define output format, jump to a test's declaration and view test history. Here you can also stop or rerun the test session in one click.
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 Show Passed option to hide successful tests.
Disable the Show Ignored option to hide ignored tests.
Click and select how you want to sort the test results:
Suites Always on Top – click to display suites on top.
Sort Alphabetically – click to sort test results alphabetically.
Sort by Duration – click to place test nodes on top of the list.
Manage test results
Click on the Test Runner toolbar, then select Test Runner Options and enable the following options:
Track Running Test: monitor execution of the current test.
Show Inline Statistics: view the execution time for tests.
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.
Show Inline Statistic: show the time of running for each test.
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.
Jump to test declaration
Select the necessary test from the list on the Test Runner tab and press F4.
View results of previous tests
CLion automatically saves results of the last 10 test sessions. To open the list of recent test sessions:
Click the icon on the Test Runner toolbar and select the necessary test session from the list.
For each test session, the list displays the run configuration name and a timestamp:
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
Click on the Test Runner toolbar, then click Export Test Results.
Select the format in which you want to save the file:
HTML: generate an HTML file from a pre-defined template.
XML: use this format if you want to import this file later to CLion.
Custom, apply XSL template: use your custom XSL template to generate an HTML file from the raw XML output. Click next to this option and select the *.xsl code style definition file.
Specify the name of the output file and its location.
If you want to open the file in your browser after you export it, select the Open exported file in browser checkbox. Click OK.
Import test results
To load a previously exported file, click on the Test Runner toolbar.
If you haven't run any tests yet, and the tool window with the Test Runner toolbar is not available, press Ctrl+Shift+A and type
Import Tests from File
.In the dialog that opens, select the .xml file with test results and click Open.