Skip to content

Commit

Permalink
junit: add skipped attribute to testsuite
Browse files Browse the repository at this point in the history
  • Loading branch information
Khady committed Dec 22, 2024
1 parent 1586a3f commit 85a5136
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
6 changes: 3 additions & 3 deletions alcotest/test/alcotest_report.expected
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<testsuites><testsuite package="junit_alcotest" id="0" name="Skip test suite" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="2" failures="0" errors="0" time="0"><properties></properties><testcase name="Skipped quick" classname="Skip test suite.Skipped tests" time="0"><skipped></skipped></testcase><testcase name="Skipped slow" classname="Skip test suite.Skipped tests" time="0"><skipped></skipped></testcase></testsuite><testsuite package="junit_alcotest" id="1" name="My first test" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="4" failures="0" errors="2" time="0"><properties></properties><testcase name="Test with unexpected exception" classname="My first test.Basic tests" time="0"><error message="test crashed" type="exception raised">Invalid_argument(&quot;7&quot;)</error></testcase><testcase name="Capitalize" classname="My first test.Basic tests" time="0"></testcase><testcase name="Add entries" classname="My first test.Basic tests" time="0"></testcase><testcase name="Test with wrong result" classname="My first test.Basic tests" time="0"><error message="test crashed" type="exception raised">Alcotest assertion failure
<testsuites><testsuite package="junit_alcotest" id="0" name="Skip test suite" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="2" failures="0" errors="0" skipped="2" time="0"><properties></properties><testcase name="Skipped quick" classname="Skip test suite.Skipped tests" time="0"><skipped></skipped></testcase><testcase name="Skipped slow" classname="Skip test suite.Skipped tests" time="0"><skipped></skipped></testcase></testsuite><testsuite package="junit_alcotest" id="1" name="My first test" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="4" failures="0" errors="2" skipped="0" time="0"><properties></properties><testcase name="Test with unexpected exception" classname="My first test.Basic tests" time="0"><error message="test crashed" type="exception raised">Invalid_argument(&quot;7&quot;)</error></testcase><testcase name="Capitalize" classname="My first test.Basic tests" time="0"></testcase><testcase name="Add entries" classname="My first test.Basic tests" time="0"></testcase><testcase name="Test with wrong result" classname="My first test.Basic tests" time="0"><error message="test crashed" type="exception raised">Alcotest assertion failure
&#27;[1mFile &quot;alcotest/junit_alcotest.ml&quot;, line 20, character 6:
&#27;[0m&#27;[31mFAIL&#27;[0m string_of_int equals to '7'

Expected: `&#27;[32m&quot;7&quot;&#27;[0m'
Received: `&#27;[31m&quot;8&quot;&#27;[0m'

</error></testcase></testsuite><testsuite package="junit_alcotest" id="2" name="My second test" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="4" failures="0" errors="2" time="0"><properties></properties><testcase name="Test with unexpected exception" classname="My second test.Basic tests" time="0"><error message="test crashed" type="exception raised">Invalid_argument(&quot;7&quot;)</error></testcase><testcase name="Capitalize" classname="My second test.Basic tests" time="0"></testcase><testcase name="Add entries" classname="My second test.Basic tests" time="0"></testcase><testcase name="Test with wrong result" classname="My second test.Basic tests" time="0"><error message="test crashed" type="exception raised">Alcotest assertion failure
</error></testcase></testsuite><testsuite package="junit_alcotest" id="2" name="My second test" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="4" failures="0" errors="2" skipped="0" time="0"><properties></properties><testcase name="Test with unexpected exception" classname="My second test.Basic tests" time="0"><error message="test crashed" type="exception raised">Invalid_argument(&quot;7&quot;)</error></testcase><testcase name="Capitalize" classname="My second test.Basic tests" time="0"></testcase><testcase name="Add entries" classname="My second test.Basic tests" time="0"></testcase><testcase name="Test with wrong result" classname="My second test.Basic tests" time="0"><error message="test crashed" type="exception raised">Alcotest assertion failure
&#27;[1mFile &quot;alcotest/junit_alcotest.ml&quot;, line 20, character 6:
&#27;[0m&#27;[31mFAIL&#27;[0m string_of_int equals to '7'

Expected: `&#27;[32m&quot;7&quot;&#27;[0m'
Received: `&#27;[31m&quot;8&quot;&#27;[0m'

</error></testcase></testsuite><testsuite package="junit_alcotest" id="3" name="Success test suite" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="2" failures="0" errors="0" time="0"><properties></properties><testcase name="Capitalize" classname="Success test suite.Good tests" time="0"></testcase><testcase name="Add entries" classname="Success test suite.Good tests" time="0"></testcase></testsuite></testsuites>
</error></testcase></testsuite><testsuite package="junit_alcotest" id="3" name="Success test suite" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="2" failures="0" errors="0" skipped="0" time="0"><properties></properties><testcase name="Capitalize" classname="Success test suite.Good tests" time="0"></testcase><testcase name="Add entries" classname="Success test suite.Good tests" time="0"></testcase></testsuite></testsuites>
8 changes: 6 additions & 2 deletions junit/junit.ml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ module Testsuite = struct
tests: int;
failures: int;
errors: int;
skipped: int;
time: float;
system_out: string option;
system_err: string option;
Expand Down Expand Up @@ -123,6 +124,7 @@ module Testsuite = struct
tests = 0;
failures = 0;
errors = 0;
skipped = 0;
time = 0.;
system_out;
system_err;
Expand All @@ -140,8 +142,9 @@ module Testsuite = struct
}
in
match testcase.Testcase.result with
| Testcase.Pass
| Testcase.Skipped -> t
| Testcase.Pass -> t
| Testcase.Skipped ->
{ t with skipped = t.skipped + 1; }
| Testcase.Error _ ->
{ t with errors = t.errors + 1; }
| Testcase.Failure _ ->
Expand Down Expand Up @@ -211,6 +214,7 @@ let to_xml (t:t) =
~tests:t.tests
~failures:t.failures
~errors:t.errors
~skipped:t.skipped
~time:t.time
properties
testcases
Expand Down
5 changes: 5 additions & 0 deletions junit/junit_xml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ type testsuite =
tests : int;
failures : int;
errors : int;
skipped : int;
time : float;
properties : properties;
testcases : testcases;
Expand All @@ -151,6 +152,7 @@ let testsuite
~tests
~failures
~errors
~skipped
~time
properties
testcases
Expand All @@ -164,6 +166,7 @@ let testsuite
tests;
failures;
errors;
skipped;
time;
properties;
testcases;
Expand All @@ -180,6 +183,7 @@ let testsuite_to_xml testsuite =
let tests = int_attrib "tests" testsuite.tests in
let failures = int_attrib "failures" testsuite.failures in
let errors = int_attrib "errors" testsuite.errors in
let skipped = int_attrib "skipped" testsuite.skipped in
let time = float_attrib "time" testsuite.time in
let attributes =
[
Expand All @@ -191,6 +195,7 @@ let testsuite_to_xml testsuite =
tests;
failures;
errors;
skipped;
time;
]
in
Expand Down
5 changes: 5 additions & 0 deletions junit/junit_xml.mli
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ val testsuite :
tests:int ->
failures:int ->
errors:int ->
skipped:int ->
time:float ->
properties ->
testcases ->
Expand Down Expand Up @@ -205,6 +206,10 @@ val testsuite :
problem. e.g., an unchecked throwable; or a problem with the
implementation of the test.
@param skipped The total number of tests in the suite that
were skipped. A skipped test is one that was not run because
the conditions for running it were not met.
@param time Time taken (in seconds) to execute the tests in the
suite.
Expand Down
2 changes: 1 addition & 1 deletion junit/test/simple.expected
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<testsuites><testsuite package="JUnitXmlReporter" id="0" name="JUnitXmlReporter" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="0" failures="0" errors="0" time="0"><properties></properties></testsuite><testsuite package="JUnitXmlReporter.constructor" id="1" name="JUnitXmlReporter.constructor" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="3" failures="1" errors="0" time="0.006"><properties><property name="project.jdk.classpath" value="jdk.classpath.1.6"></property><property name="compiler.debug" value="on"></property><property name="java.vendor" value="Sun Microsystems Inc."></property></properties><testcase name="should default useDotNotation to true" classname="JUnitXmlReporter.constructor" time="0"></testcase><testcase name="should default consolidate to true" classname="JUnitXmlReporter.constructor" time="0"><skipped></skipped></testcase><testcase name="should default path to an empty string" classname="JUnitXmlReporter.constructor" time="0.006"><failure message="test failure" type="not equal">Assertion failed</failure></testcase></testsuite></testsuites>
<testsuites><testsuite package="JUnitXmlReporter" id="0" name="JUnitXmlReporter" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="0" failures="0" errors="0" skipped="0" time="0"><properties></properties></testsuite><testsuite package="JUnitXmlReporter.constructor" id="1" name="JUnitXmlReporter.constructor" timestamp="2013-05-24T10:23:58" hostname="localhost" tests="3" failures="1" errors="0" skipped="1" time="0.006"><properties><property name="project.jdk.classpath" value="jdk.classpath.1.6"></property><property name="compiler.debug" value="on"></property><property name="java.vendor" value="Sun Microsystems Inc."></property></properties><testcase name="should default useDotNotation to true" classname="JUnitXmlReporter.constructor" time="0"></testcase><testcase name="should default consolidate to true" classname="JUnitXmlReporter.constructor" time="0"><skipped></skipped></testcase><testcase name="should default path to an empty string" classname="JUnitXmlReporter.constructor" time="0.006"><failure message="test failure" type="not equal">Assertion failed</failure></testcase></testsuite></testsuites>

0 comments on commit 85a5136

Please sign in to comment.