Giter Club home page Giter Club logo

go-junit's Issues

Allow reading a message from failure tag

Consider following example. Currently there is no way to read CDATA from <failure>...</failure> tag.

	<testsuite name="github.com/stackrox/rox/central/resourcecollection/datastore/store/postgres" tests="1" failures="1" errors="0" id="78" hostname="merge-go-postgres-tests-stackrox-initial" time="2.751" timestamp="2022-10-11T13:32:27Z">
		<properties>
			<property name="coverage.statements.pct" value="49.00"></property>
		</properties>
		<testcase name="TestCollectionsStore" classname="github.com/stackrox/rox/central/resourcecollection/datastore/store/postgres" time="2.330">
			<failure message="Failed"><![CDATA[    env_isolator.go:41: EnvIsolator: Setting ROX_POSTGRES_DATASTORE to true]]></failure>
		</testcase>
	</testsuite>

Expose suite timestamp

Many junit files (including readme example) have timestamp. It will be nice if this timestamp be available in suite structure.

<testsuite name="JUnitXmlReporter.constructor" timestamp="2013-05-24T10:23:58">

Expose skipped message

The Junit schema allows results to present a message as a child of a skipped element. It would be useful to be able to access that through go-junit. An example is below:

<testsuites>
    <testsuite tests="1" failures="0" time="" name="demo">
        <testcase classname="demo.case" name="test">
            <skipped message="reason"></skipped>
        </testcase>
    </testsuite>
</testsuites>

The source for this is line 335 of http://svn.apache.org/repos/asf/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit/XMLJUnitResultFormatter.java

JUnit XML examples in the wild

Given the inconsistent and the property-based nature of the JUnit "spec", it is often the case where tests/suites may be rendered much differently by one tool or another.

If you have a novel JUnit XML file (especially if go-junit fails to parse it completely/sufficiently) please post it here (but anonymize its contents first).


Please include some brief information like:

  • Name of the tool that generated the XML file.
  • A link to its homepage.
  • A link, gist, or code block of the XML file.
  • Any notes on parsing errors, or missing information.

Use time in suite if provided

I have a junit xml like this:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="client" tests="72" failures="0" errors="0" time="2.176">
  <testsuite name="src/__tests__/1.test.ts" errors="0" failures="0" skipped="0" timestamp="2023-03-01T22:51:14" time="1.56" tests="7">
    <testcase classname="1 hook" name="should set a" time="0.029">
    </testcase>
    <testcase classname="1 hook" name="should set b" time="0.006">
    </testcase>
    <testcase classname="1 hook" name="should set c" time="0.005">
    </testcase>
    <testcase classname="1 hook" name="should set d" time="0.004">
    </testcase>
    <testcase classname="1 hook" name="should set e" time="0.007">
    </testcase>
    <testcase classname="1 hook" name="should set f" time="0.003">
    </testcase>
    <testcase classname="1 hook" name="should set g" time="0.01">
    </testcase>
  </testsuite>
  <testsuite name="src/__tests__/2.test.tsx" errors="0" failures="0" skipped="0" timestamp="2023-03-01T22:51:14" time="1.623" tests="6">
    <testcase classname="2" name="should set a" time="0.051">
    </testcase>
    <testcase classname="2" name="should set b" time="0.005">
    </testcase>
    <testcase classname="2" name="should set c" time="0.009">
    </testcase>
    <testcase classname="2" name="should set d" time="0.014">
    </testcase>
    <testcase classname="2" name="should set e" time="0.015">
    </testcase>
    <testcase classname="2" name="should set f" time="0.004">
    </testcase>
  </testsuite>
</testsuites>

(this is from the output of https://www.npmjs.com/package/jest-junit)

Expected

I expect the suites' totals.duration to match the time mentioned in the testsuite itself rather than be the sum of times in testcases.

Actual

The totals.duration is the sum of the testcases. This leaves out the time spent by the testsuite in setup and teardown which is not part of any 1 individual test case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.