{"id":22282060,"url":"https://github.com/xmlunit/xmlunit","last_synced_at":"2025-05-14T03:07:28.581Z","repository":{"id":24325115,"uuid":"27721932","full_name":"xmlunit/xmlunit","owner":"xmlunit","description":"XMLUnit for Java 2.x","archived":false,"fork":false,"pushed_at":"2025-03-29T15:19:04.000Z","size":3758,"stargazers_count":304,"open_issues_count":13,"forks_count":76,"subscribers_count":24,"default_branch":"main","last_synced_at":"2025-04-03T03:31:36.738Z","etag":null,"topics":["java","test-xml","testing","unit-testing","xml","xmlunit"],"latest_commit_sha":null,"homepage":"https://www.xmlunit.org/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xmlunit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-08T15:45:12.000Z","updated_at":"2025-03-29T15:41:00.000Z","dependencies_parsed_at":"2024-01-21T11:28:47.420Z","dependency_job_id":"ba65c434-909d-4f0f-be77-f3b25ad89d1b","html_url":"https://github.com/xmlunit/xmlunit","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlunit%2Fxmlunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlunit%2Fxmlunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlunit%2Fxmlunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xmlunit%2Fxmlunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xmlunit","download_url":"https://codeload.github.com/xmlunit/xmlunit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248166853,"owners_count":21058481,"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":["java","test-xml","testing","unit-testing","xml","xmlunit"],"created_at":"2024-12-03T16:25:06.883Z","updated_at":"2025-05-14T03:07:28.562Z","avatar_url":"https://github.com/xmlunit.png","language":"Java","readme":"XMLUnit for Java 2.x\n====================\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/org.xmlunit/xmlunit-core/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.xmlunit/xmlunit-core)\n\n[![CircleCI Build Status XMLUnit 2.x for Java](https://dl.circleci.com/status-badge/img/circleci/V6g9K7YQzERoCkGuNKbmF2/NCancriyEKnFRq6b7UPeyc/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/circleci/V6g9K7YQzERoCkGuNKbmF2/NCancriyEKnFRq6b7UPeyc/tree/main) [![Coverage Status](https://coveralls.io/repos/github/xmlunit/xmlunit/badge.svg)](https://coveralls.io/github/xmlunit/xmlunit)\n\nXMLUnit is a library that supports testing XML output in several ways.\n\nXMLUnit 2.x is a complete rewrite of XMLUnit and actually doesn't\nshare any code with XMLUnit for Java 1.x.\n\nSome goals for XMLUnit 2.x:\n\n* create .NET and Java versions that are compatible in design while\n  trying to be idiomatic for each platform\n* remove all static configuration (the old XMLUnit class setter methods)\n* focus on the parts that are useful for testing\n  - XPath\n  - (Schema) validation\n  - comparisons\n* be independent of any test framework\n\nXMLUnit 1.x is no longer maintained, you can still find the old forum over at\n[sourceforge](https://sourceforge.net/projects/xmlunit/) and we still use the\nsourceforge provided mailing list.\n\n## Documentation\n\n* [Developer Guide](https://github.com/xmlunit/xmlunit/wiki)\n* [User's Guide](https://github.com/xmlunit/user-guide/wiki)\n\n## Help Wanted!\n\nIf you are looking for something to work on, we've compiled a\n[list](HELP_WANTED.md) of known issues.\n\nPlease see the [contributing guide](CONTRIBUTING.md) for details on\nhow to contribute.\n\n## Latest Release\n\nThe latest releases are available as\n[GitHub releases](https://github.com/xmlunit/xmlunit/releases) or via\n[Maven Central](http://search.maven.org/#search|ga|1|org.xmlunit).\n\nThe core library is\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.xmlunit\u003c/groupId\u003e\n  \u003cartifactId\u003exmlunit-core\u003c/artifactId\u003e\n  \u003cversion\u003ex.y.z\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## SNAPSHOT builds\n\nWe are providing SNAPSHOT builds from\n[Sonatype's Central Portal Snapshots](https://central.sonatype.com/service/rest/repository/browse/maven-snapshots/org/xmlunit/),\nyou need to add\n\n```xml\n\u003crepository\u003e\n  \u003cname\u003eCentral Portal Snapshots\u003c/name\u003e\n  \u003cid\u003ecentral-portal-snapshots\u003c/id\u003e\n  \u003curl\u003ehttps://central.sonatype.com/repository/maven-snapshots/\u003c/url\u003e\n  \u003creleases\u003e\u003cenabled\u003efalse\u003c/enabled\u003e\u003c/releases\u003e\n  \u003csnapshots\u003e\u003cenabled\u003etrue\u003c/enabled\u003e\u003c/snapshots\u003e\n\u003c/repository\u003e\n```\n\nto your Maven settings.\n\n## Examples\n\nThese are some really small examples, more is available as part of the\n[user guide](https://github.com/xmlunit/user-guide/wiki)\n\n### Comparing Two Documents\n\n```java\nSource control = Input.fromFile(\"test-data/good.xml\").build();\nSource test = Input.fromByteArray(createTestDocument()).build();\nDifferenceEngine diff = new DOMDifferenceEngine();\ndiff.addDifferenceListener(new ComparisonListener() {\n        public void comparisonPerformed(Comparison comparison, ComparisonResult outcome) {\n            Assert.fail(\"found a difference: \" + comparison);\n        }\n    });\ndiff.compare(control, test);\n```\n\nor using the fluent builder API\n\n```java\nDiff d = DiffBuilder.compare(Input.fromFile(\"test-data/good.xml\"))\n             .withTest(createTestDocument()).build();\nassert !d.hasDifferences();\n```\n\nor using Hamcrest with `CompareMatcher`\n\n```java\nimport static org.xmlunit.matchers.CompareMatcher.isIdenticalTo;\n...\n\nassertThat(createTestDocument(), isIdenticalTo(Input.fromFile(\"test-data/good.xml\")));\n```\n\nor using AssertJ with `XmlAssert` of the `xmlunit-assertj` module\n\n```java\n\nimport static org.xmlunit.assertj.XmlAssert.assertThat;\n...\n\nassertThat(createTestDocument())\n            .and(Input.fromFile(\"test-data/good.xml\"))\n            .areIdentical();\n```\n\nor using AssertJ with `XmlAssert` of the `xmlunit-assertj3` module\n\n```java\n\nimport static org.xmlunit.assertj3.XmlAssert.assertThat;\n...\n\nassertThat(createTestDocument())\n            .and(Input.fromFile(\"test-data/good.xml\"))\n            .areIdentical();\n```\n\n### Asserting an XPath Value\n\n```java\nSource source = Input.fromString(\"\u003cfoo\u003ebar\u003c/foo\u003e\").build();\nXPathEngine xpath = new JAXPXPathEngine();\nIterable\u003cNode\u003e allMatches = xpath.selectNodes(\"/foo\", source);\nassert allMatches.iterator().hasNext();\nString content = xpath.evaluate(\"/foo/text()\", source);\nassert \"bar\".equals(content);\n```\n\nor using Hamcrest with `HasXPathMatcher`, `EvaluateXPathMatcher`\n\n```java\nassertThat(\"\u003cfoo\u003ebar\u003c/foo\u003e\", HasXPathMatcher.hasXPath(\"/foo\"));\nassertThat(\"\u003cfoo\u003ebar\u003c/foo\u003e\", EvaluateXPathMatcher.hasXPath(\"/foo/text()\",\n                                                           equalTo(\"bar\")));\n```\n\nor using AssertJ with `XmlAssert` of the `xmlunit-assertj` module\n\n```java\n\nimport static org.xmlunit.assertj.XmlAssert.assertThat;\n...\n\nassertThat(\"\u003cfoo\u003ebar\u003c/foo\u003e\").hasXPath(\"/foo\");\nassertThat(\"\u003cfoo\u003ebar\u003c/foo\u003e\").valueByXPath(\"/foo/text()\").isEqualTo(\"bar\");\n```\n\nor using AssertJ with `XmlAssert` of the `xmlunit-assertj3` module\n\n```java\n\nimport static org.xmlunit.assertj3.XmlAssert.assertThat;\n...\n\nassertThat(\"\u003cfoo\u003ebar\u003c/foo\u003e\").hasXPath(\"/foo\");\nassertThat(\"\u003cfoo\u003ebar\u003c/foo\u003e\").valueByXPath(\"/foo/text()\").isEqualTo(\"bar\");\n```\n\n### Validating a Document Against an XML Schema\n\n```java\nValidator v = Validator.forLanguage(Languages.W3C_XML_SCHEMA_NS_URI);\nv.setSchemaSources(Input.fromUri(\"http://example.com/some.xsd\").build(),\n                   Input.fromFile(\"local.xsd\").build());\nValidationResult result = v.validateInstance(Input.fromDocument(createDocument()).build());\nboolean valid = result.isValid();\nIterable\u003cValidationProblem\u003e problems = result.getProblems();\n```\n\nor using Hamcrest with `ValidationMatcher`\n\n```java\nimport static org.xmlunit.matchers.ValidationMatcher.valid;\n...\n\nassertThat(createDocument(), valid(Input.fromFile(\"local.xsd\")));\n```\n\nor using AssertJ with `XmlAssert` of the `xmlunit-assertj` module\n\n```java\nimport static org.xmlunit.assertj.XmlAssert.assertThat;\n...\n\nassertThat(createDocument()).isValidAgainst(Input.fromFile(\"local.xsd\"));\n```\n\nor using AssertJ with `XmlAssert` of the `xmlunit-assertj3` module\n\n```java\nimport static org.xmlunit.assertj3.XmlAssert.assertThat;\n...\n\nassertThat(createDocument()).isValidAgainst(Input.fromFile(\"local.xsd\"));\n```\n\n## Requirements\n\nStarting with version 2.8.0 XMLUnit requires Java 7, which has always\nbeen the minimum requirement for the AssertJ module. All other modules\nin versions 2.0.0 to 2.7.0 required Java 6. The `xmlunit-assertj3`\nmodule requires Java 8 as does AssertJ 3.x itself.\n\nThe `core` library provides all functionality needed to test XML\noutput and hasn't got any dependencies.  It uses JUnit 4.x for its own\ntests.\n\nIf you want to use `Input.fromJaxb` - i.e. you want to serialize plain Java objects to XML as input - then you may also\nneed to add a dependency on the JAXB implementation. For more details see the [User's\nGuide](https://github.com/xmlunit/user-guide/wiki/JAXB).\n\nThe core library is complemented by Hamcrest 1.x matchers and AssertJ\nassertions.  There also exists a `legacy` project that provides the\nAPI of XMLUnit 1.x on top of the 2.x core library.\n\nWhile the Hamcrest matchers are built against Hamcrest 1.x they are\nsupposed to work with Hamcrest 2.x as well.\n\nStarting with XMLUnit 2.8.1 there are two different AssertJ modules,\n`xmlunit-assertj` is the original implementation which is based on\nAssertJ 2.x and also works for AssertJ 3.x but uses reflection to deal\nwith some changes in later versions of AssertJ. The `xmlunit-assertj3`\nmodule requires at least AssertJ 3.18.1.\n\nThe `xmlunit-assertj` module depends on an internal package not\nexported by AssertJ's OSGi module and thus doesn't work in an OSGi\ncontext.\n\nAnother difference between the two AssertJ modules is the exception\nthrown if a comparison fails. `xmlunit-assertj` will try to throw a\nJUnit 4.x `ComparisonFailure` if the class is available and thus is\nbest suited for tests using JUnit 4.x. `xmlunit-assertj3` will try to\nthrow an [Open Test\nAlliance](https://github.com/ota4j-team/opentest4j)\n`AssertionFailedError` if the class is available and thus is better\nsuited for tests using JUnit 5.x.\n\n## Checking out XMLUnit for Java\n\nXMLUnit for Java uses a git submodule for test resources it shares\nwith XMLUnit.NET.  You can either clone this repository using `git\nclone --recursive` or run `git submodule update --init` inside\nyour fresh working copy after cloning normally.\n\nIf you have checked out a working copy before we added the submodule,\nyou'll need to run `git submodule update --init` once.\n\n## Building\n\nXMLUnit for Java builds using Apache Maven 3.x, mainly you want to run\n\n```sh\n$ mvn install\n```\n\nin order to compile all modules and run the tests.\n","funding_links":[],"categories":["Projects","测试","项目","Five Java Libraries to amplify your automated testing"],"sub_categories":["Testing","测试"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmlunit%2Fxmlunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxmlunit%2Fxmlunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxmlunit%2Fxmlunit/lists"}