Export Test Results

You can export test results in the JUnit XML format specified here. You can specify a file name to export to, or kick off an export in a post-run hook.

Setting the export file

There are two settings, the file name and a flag to include an epoch timestamp in the filename. The epoch timestamp will prevent runs from overwriting the last run’s file.

  • Gut Panel

    • Set Output Path in the XML Output section in the Gut Panel

    • Check Include Timestamp if you want the timestamp to be included.

  • Command Line

    • Set -gjunit_xml_file to the path.

    • Add option -gjunit_xml_timestamp to include the timestamp.

  • .gutconfig.json File

    • "junit_xml_file":"user://resutls.xml"

    • "junit_xml_timestamp":false

  • Inspector

    • Set Junit Xml File to the path.

    • Check Junit Xml Timestamp if you want the timestamp to be included.

Example Output

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="GutTests" failures="7" tests="17">
      <testsuite name="res://test/resources/exporter_test_files/test_simple_2.gd" tests="3" failures="1" skipped="1">
            <testcase name="test_pass" assertions="1" status="pass" classname="res://test/resources/exporter_test_files/test_simple_2.gd"></testcase>
            <testcase name="test_fail" assertions="1" status="fail" classname="res://test/resources/exporter_test_files/test_simple_2.gd">
                  <failure message="failed">Cannot compare Int[1] to String["two"].
            at line 7</failure>
            </testcase>
            <testcase name="test_pending" assertions="0" status="pending" classname="res://test/resources/exporter_test_files/test_simple_2.gd">
                  <skipped message="pending">this has text</skipped>
            </testcase>
      </testsuite>
      <testsuite name="res://test/resources/exporter_test_files/test_simple.gd" tests="8" failures="4" skipped="2">
            <testcase name="test_pending_with_text" assertions="0" status="pending" classname="res://test/resources/exporter_test_files/test_simple.gd">
                  <skipped message="pending">this has text</skipped>
            </testcase>
            <testcase name="test_parameterized_passing" assertions="4" status="pass" classname="res://test/resources/exporter_test_files/test_simple.gd"></testcase>
            <testcase name="test_parameterized_failing" assertions="2" status="fail" classname="res://test/resources/exporter_test_files/test_simple.gd">
                  <failure message="failed">(call #1) [1] expected to equal [2]:
            at line 25</failure>
            </testcase>
            <testcase name="test_fail_2" assertions="1" status="fail" classname="res://test/resources/exporter_test_files/test_simple.gd">
                  <failure message="failed">Cannot compare String["two"] to Int[2].
            at line 13</failure>
            </testcase>
            <testcase name="test_pending_no_text" assertions="0" status="pending" classname="res://test/resources/exporter_test_files/test_simple.gd">
                  <skipped message="pending"></skipped>
            </testcase>
            <testcase name="test_pass_1" assertions="1" status="pass" classname="res://test/resources/exporter_test_files/test_simple.gd"></testcase>
            <testcase name="test_pass_2" assertions="1" status="pass" classname="res://test/resources/exporter_test_files/test_simple.gd"></testcase>
            <testcase name="test_fail_1" assertions="1" status="fail" classname="res://test/resources/exporter_test_files/test_simple.gd">
                  <failure message="failed">Cannot compare Int[1] to String["two"].
            at line 10</failure>
            </testcase>
      </testsuite>
      <testsuite name="res://test/resources/exporter_test_files/test_with_inner_classes.gd" tests="0" failures="0" skipped="0"></testsuite>
      <testsuite name="res://test/resources/exporter_test_files/test_with_inner_classes.gd.TestClassOne" tests="3" failures="1" skipped="1">
            <testcase name="test_pending_with_text" assertions="0" status="pending" classname="res://test/resources/exporter_test_files/test_with_inner_classes.gd.TestClassOne">
                  <skipped message="pending">this has text</skipped>
            </testcase>
            <testcase name="test_fail_1" assertions="1" status="fail" classname="res://test/resources/exporter_test_files/test_with_inner_classes.gd.TestClassOne">
                  <failure message="failed">Cannot compare Int[1] to String["two"].
            at line 11</failure>
            </testcase>
            <testcase name="test_pass_1" assertions="1" status="pass" classname="res://test/resources/exporter_test_files/test_with_inner_classes.gd.TestClassOne"></testcase>
      </testsuite>
      <testsuite name="res://test/resources/exporter_test_files/test_with_inner_classes.gd.TestClassTwo" tests="3" failures="1" skipped="1">
            <testcase name="test_pending_with_text" assertions="0" status="pending" classname="res://test/resources/exporter_test_files/test_with_inner_classes.gd.TestClassTwo">
                  <skipped message="pending">this has text</skipped>
            </testcase>
            <testcase name="test_fail_1" assertions="1" status="fail" classname="res://test/resources/exporter_test_files/test_with_inner_classes.gd.TestClassTwo">
                  <failure message="failed">Cannot compare Int[1] to String["two"].
            at line 26</failure>
            </testcase>
            <testcase name="test_pass_1" assertions="1" status="pass" classname="res://test/resources/exporter_test_files/test_with_inner_classes.gd.TestClassTwo"></testcase>
      </testsuite>
</testsuites>

Exporting results in post-run Hook

If you would like more control over exporting the results you can do so manually in a post-run hook. See Hooks for more information about setting up a post-run script.

Note that JunitXmlExport and gut are defined by the parent script res://addons/gut/hook_script.gd

extends GutHookScript

func run() # called automatically by Gut
	var exporter = JunitXmlExport.new()
    var filename = 'user://my_post_hook_results.xml'
	var f_result = exporter.write_file(gut, filename)
	if(f_result == OK):
		gut.p(str("Results saved to ", filename))