8000 GitHub - vlow/majx: Matching JSON expressively
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

vlow/majx

 
 

Repository files navigation

majx Logo

Matching JSON expressively

Build Status Coverage Status License Download

Majx is a test library for the JVM written in Kotlin that verifies that a JSON document fulfils your expectations regarding structure and values.

You provide two JSON documents

  1. The actual JSON that should be tested
  2. The pattern JSON that describes your expectations

We try to let you express almost all of your expectations in a flexible, readable and concise way within the pattern. To achieve this, the pattern may contain magic values, that are treated in a certain way.

Usage

Obtain a reference to the actual and pattern JSONs as String or jackson's JsonNode and pass them to one of the static methods that the class Majx provides.

String actual  = "{ \"greeting\" : \"Hello, World!\", \"id\" : 12 }";
String pattern = "{ \"greeting\" : \"Hello, World!\", \"id\" : \"...\" }";

Majx.assertJsonMatches(pattern, actual);

This test would succeed for any value for the "id" property inside the actual JSON since its expected value is the magic "..."-wildcard value in the pattern (See Ignoring values).

Details on all available features can be found in the wiki:

Dependencies

The JARs are available via Maven Central and JCenter.

If you are using Maven to build your project, add the following to the pom.xml file.

<!-- https://mvnrepository.com/artifact/de.qaware.majx/majx -->
<dependency>
    <groupId>de.qaware.majx</groupId>
    <artifactId>majx</artifactId>
    <version>1.0.1</version>
    <scope>test</scope>
</dependency>

In case you are using Gradle to build your project, add the following to the build.gradle file:

repositories {
    jcenter()
    mavenCentral()
}

dependencies {
    // https://mvnrepository.com/artifact/de.qaware.majx/majx
    testCompile group: 'de.qaware.majx', name: 'majx', version: '1.0.1'
}

Related Work

Maintainer

Claudius Boettcher, claudius.boettcher@qaware.de.

License

This software is provided under the MIT open source license, read the LICENSE file for details.

About

Matching JSON expressively

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 61.2%
  • Kotlin 38.8%
0