|
1 | 1 | [](https://travis-ci.org/stringbean/scala-xml-compare)
|
| 2 | +[](https://www.codacy.com/app/stringbean/scala-xml-compare) |
2 | 3 | [](https://codecov.io/gh/stringbean/scala-xml-compare)
|
3 | 4 | [](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22software.purpledragon%22%20a%3A%22xml-compare_2.11%22)
|
4 | 5 | [](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22software.purpledragon%22%20a%3A%22xml-compare_2.12%22)
|
| 6 | +[](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22software.purpledragon%22%20a%3A%22xml-compare_2.13.0-M5%22) |
5 | 7 |
|
6 |
| -# XML Comparison Utils for Scala |
| 8 | +# XML Comparison Utils for Scala |
| 9 | + |
| 10 | +`scala-xml-compare` is a small Scala library for comparing XML documents. |
| 11 | + |
| 12 | +## Quickstart |
| 13 | + |
| 14 | +Add the following to your `build.sbt`: |
| 15 | + |
| 16 | +```scala |
| 17 | +libraryDependencies += "purpledragon.software" %% "scala-xml" % "<version>" |
| 18 | +``` |
| 19 | + |
| 20 | +You can then compare XML using: |
| 21 | + |
| 22 | +```scala |
| 23 | +val doc1 = <person><name>John Smith</name></person> |
| 24 | +val doc2 = <person><name>Peter Smith</name></person> |
| 25 | + |
| 26 | +val result = XmlCompare.compare(doc1, doc2) |
| 27 | +// result1 = XmlDiffers("different text", "John Smith", "Peter Smith") |
| 28 | +``` |
| 29 | + |
| 30 | +### Scalatest |
| 31 | + |
| 32 | +A companion library is provided for testing XML in Scalatest: |
| 33 | + |
| 34 | +```scala |
| 35 | +libraryDependencies += "purpledragon.software" %% "scala-scalatest" % "<version>" % Test |
| 36 | +``` |
| 37 | + |
| 38 | +This then enables the `beXml` matcher: |
| 39 | + |
| 40 | +```scala |
| 41 | +val doc = <person><name>John Smith</name></person> |
| 42 | +doc should beXml(<person><name>John Smith</name></person>) |
| 43 | +``` |
| 44 | + |
| 45 | +### specs2 |
| 46 | + |
| 47 | +Similarly a companion library for specs2 is provided: |
| 48 | + |
| 49 | +```scala |
| 50 | +libraryDependencies += "purpledragon.software" %% "scala-specs2" % "<version>" % Test |
| 51 | +``` |
0 commit comments