joshdk / go-junit Goto Github PK
View Code? Open in Web Editor NEW๐ Go library for ingesting JUnit XML reports
License: MIT License
๐ Go library for ingesting JUnit XML reports
License: MIT License
I would like to use the status
type (https://github.com/joshdk/go-junit/blob/master/types.go#L7) to enforce type safety but it is currently private to the package. Could we make this public?
Look into removing testify
from the tests. It's only really used for asserts, and is the only dependency in the repo.
Would removing this dependency be worth the loss of test usability?
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>
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">
The Suite
and Error
types are inconsistent with their usage of the omitempty
json/yaml struct tag.
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
Exercise the various ingestion methods via unit tests.
Thanks for writing this, it's helpful!
I'm surprised at the number of dependencies you've added.
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:
Write an example ingestion test that can be run on godoc.org.
Some folks (like cirruslabs/cirrus-ci-annotations) depend on this library. Create a release tag so that they can pin their dependency easier.
Write a test that validates that a full Suite
can be marshalled as JSON and YAML, and that it remains intact when unmarshalled back.
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)
I expect the suites' totals.duration to match the time mentioned in the testsuite
itself rather than be the sum of times in testcases.
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.
For tests longer than 17 minutes, the duration field goes into 4 digits. The maven surefire plugin outputs this in a comma separated format, e.g, 1,234.56. We should remove commas before trying to parse the duration field. Ref: junit-team/junit5#1381
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.