{"id":20532478,"url":"https://github.com/joshdk/go-junit","last_synced_at":"2026-03-15T01:09:52.094Z","repository":{"id":31005827,"uuid":"126570143","full_name":"joshdk/go-junit","owner":"joshdk","description":"🐜 Go library for ingesting JUnit XML reports","archived":false,"fork":false,"pushed_at":"2023-05-06T10:24:50.000Z","size":132,"stargazers_count":59,"open_issues_count":10,"forks_count":21,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-10T23:41:31.637Z","etag":null,"topics":["go","golang","hacktoberfest","junit","junit-report","junit-test","junit-xml","xml"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joshdk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-24T05:49:42.000Z","updated_at":"2024-10-01T12:42:00.000Z","dependencies_parsed_at":"2024-06-18T14:02:18.588Z","dependency_job_id":"287215e9-7a57-4aca-9700-eec10875ff8b","html_url":"https://github.com/joshdk/go-junit","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fgo-junit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fgo-junit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fgo-junit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joshdk%2Fgo-junit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joshdk","download_url":"https://codeload.github.com/joshdk/go-junit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230438185,"owners_count":18225870,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","hacktoberfest","junit","junit-report","junit-test","junit-xml","xml"],"created_at":"2024-11-16T00:15:07.283Z","updated_at":"2026-03-15T01:09:47.042Z","avatar_url":"https://github.com/joshdk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License][license-badge]][license-link]\n[![Actions][github-actions-badge]][github-actions-link]\n[![Go Report Card][go-report-badge]][go-report-link]\n[![Go Dev][godev-badge]][godev-link]\n[![Releases][github-release-badge]][github-release-link]\n\n# Go JUnit\n\n🐜 Go library for ingesting JUnit XML reports\n\n## Installing\n\nYou can fetch this library by running the following\n\n```bash\ngo get -u github.com/joshdk/go-junit\n```\n\n## Usage\n\n### Data Ingestion\n\nThis library has a number of ingestion methods for convenience.\n\nThe simplest of which parses raw JUnit XML data.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003ctestsuites\u003e\n    \u003ctestsuite name=\"JUnitXmlReporter.constructor\" errors=\"0\" skipped=\"1\" tests=\"3\" failures=\"1\" time=\"0.006\" timestamp=\"2013-05-24T10:23:58\"\u003e\n        \u003cproperties\u003e\n            \u003cproperty name=\"java.vendor\" value=\"Sun Microsystems Inc.\" /\u003e\n            \u003cproperty name=\"compiler.debug\" value=\"on\" /\u003e\n            \u003cproperty name=\"project.jdk.classpath\" value=\"jdk.classpath.1.6\" /\u003e\n        \u003c/properties\u003e\n        \u003ctestcase classname=\"JUnitXmlReporter.constructor\" name=\"should default path to an empty string\" time=\"0.006\"\u003e\n            \u003cfailure message=\"test failure\"\u003eAssertion failed\u003c/failure\u003e\n        \u003c/testcase\u003e\n        \u003ctestcase classname=\"JUnitXmlReporter.constructor\" name=\"should default consolidate to true\" time=\"0\"\u003e\n            \u003cskipped /\u003e\n        \u003c/testcase\u003e\n        \u003ctestcase classname=\"JUnitXmlReporter.constructor\" name=\"should default useDotNotation to true\" time=\"0\" /\u003e\n    \u003c/testsuite\u003e\n\u003c/testsuites\u003e\n```\n\n```go\nxml := []byte(`\u003c?xml …`)\n\nsuites, err := junit.Ingest(xml)\n```\n\nYou can then inspect the contents of the ingested suites.\n\n```go\nfor _, suite := range suites {\n    fmt.Println(suite.Name)\n    for _, test := range suite.Tests {\n        fmt.Printf(\"  %s\\n\", test.Name)\n        if test.Error != nil {\n            fmt.Printf(\"    %s: %v\\n\", test.Status, test.Error)\n        } else {\n            fmt.Printf(\"    %s\\n\", test.Status)\n        }\n    }\n}\n```\n\nAnd observe some output like this.\n\n```\nJUnitXmlReporter.constructor\n  should default path to an empty string\n    failed: Assertion failed\n  should default consolidate to true\n    skipped\n  should default useDotNotation to true\n    passed\n```\n\n### More Examples\n\nAdditionally, you can ingest an entire file.\n\n```go\nsuites, err := junit.IngestFile(\"test-reports/report.xml\")\n```\n\nOr a list of multiple files.\n\n```go\nsuites, err := junit.IngestFiles([]string{\n    \"test-reports/report-1.xml\",\n    \"test-reports/report-2.xml\",\n})\n```\n\nOr any `.xml` files inside of a directory.\n\n```go\nsuites, err := junit.IngestDir(\"test-reports/\")\n```\n\n### Data Formats\n\nDue to the lack of implementation consistency in software that generates JUnit XML files, this library needs to take a somewhat looser approach to ingestion. As a consequence, many different possible JUnit formats can easily be ingested.\n\nA single top level `testsuite` tag, containing multiple `testcase` instances.\n\n```xml\n\u003ctestsuite\u003e\n    \u003ctestcase name=\"Test case 1\" /\u003e\n    \u003ctestcase name=\"Test case 2\" /\u003e\n\u003c/testsuite\u003e\n```\n\nA single top level `testsuites` tag, containing multiple `testsuite` instances.\n\n```xml\n\u003ctestsuites\u003e\n    \u003ctestsuite\u003e\n        \u003ctestcase name=\"Test case 1\" /\u003e\n        \u003ctestcase name=\"Test case 2\" /\u003e\n    \u003c/testsuite\u003e\n\u003c/testsuites\u003e\n```\n\n(Despite not technically being valid XML) Multiple top level `testsuite` tags, containing multiple `testcase` instances.\n\n```xml\n\u003ctestsuite\u003e\n    \u003ctestcase name=\"Test case 1\" /\u003e\n    \u003ctestcase name=\"Test case 2\" /\u003e\n\u003c/testsuite\u003e\n\u003ctestsuite\u003e\n    \u003ctestcase name=\"Test case 3\" /\u003e\n    \u003ctestcase name=\"Test case 4\" /\u003e\n\u003c/testsuite\u003e\n```\n\nIn all cases, omitting (or even duplicated) the XML declaration tag is allowed.\n\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n```\n\n## Contributing\n\nFound a bug or want to make go-junit better? Please [open a pull request](https://github.com/joshdk/go-junit/compare)!\n\nTo make things easier, try out the following:\n\n- Running `go test -v` will run the test suite to verify behavior.\n\n- Running `golangci-lint run` will report any linting issues using [golangci/golangci-lint](https://github.com/golangci/golangci-lint/releases/tag/v1.50.1).\n\n## License\n\nThis code is distributed under the [MIT License][license-link], see [LICENSE.txt][license-file] for more information.\n\n\u003cp align=\"center\"\u003e\n  Created by \u003ca href=\"https://github.com/joshdk\"\u003eJosh Komoroske\u003c/a\u003e ☕\n\u003c/p\u003e\n\n[github-actions-badge]:  https://github.com/joshdk/go-junit/workflows/Test/badge.svg?branch=master\n[github-actions-link]:   https://github.com/joshdk/go-junit/actions\n[github-release-badge]:  https://img.shields.io/github/release/joshdk/go-junit/all.svg\n[github-release-link]:   https://github.com/joshdk/go-junit/releases\n[go-report-badge]:       https://goreportcard.com/badge/github.com/joshdk/go-junit\n[go-report-link]:        https://goreportcard.com/report/github.com/joshdk/go-junit\n[godev-badge]:           https://pkg.go.dev/badge/github.com/joshdk/go-junit.svg\n[godev-link]:            https://pkg.go.dev/github.com/joshdk/go-junit\n[license-badge]:         https://img.shields.io/badge/license-MIT-green.svg\n[license-file]:          https://github.com/joshdk/go-junit/blob/master/LICENSE.txt\n[license-link]:          https://opensource.org/licenses/MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshdk%2Fgo-junit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoshdk%2Fgo-junit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoshdk%2Fgo-junit/lists"}