Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test Fails Without Manually Adding Logging Dependency #595

Closed
SenorPez opened this issue Jan 26, 2023 · 2 comments
Closed

Test Fails Without Manually Adding Logging Dependency #595

SenorPez opened this issue Jan 26, 2023 · 2 comments

Comments

@SenorPez
Copy link

Describe the bug

  1. Describe which variant of the API are you using (AssertJ, Hamcrest, ...)

AssertJ

  1. Create a small reproducible example and paste it the the bug report.

Dependencies (Gradle JVM Test Suite DSL) (excerpt)

        integrationTest(JvmTestSuite) {
            dependencies {
                implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.1'
                implementation 'net.javacrumbs.json-unit:json-unit-assertj:2.36.0'
            }
        }

Test

    @Test
    void testTest() {
        assertThatJson("{\"id\":\"1\", \"children\":[{\"parentId\":\"1\"}]}")
                .inPath("children[*].parentId")
                .isArray()
                .containsOnly(value("1"));

Result

org/slf4j/LoggerFactory
java.lang.NoClassDefFoundError: org/slf4j/LoggerFactory
	at com.jayway.jsonpath.internal.JsonContext.<clinit>(JsonContext.java:41)
	at com.jayway.jsonpath.internal.ParseContextImpl.parse(ParseContextImpl.java:38)
	at net.javacrumbs.jsonunit.jsonpath.InternalJsonPathUtils.readValue(InternalJsonPathUtils.java:69)
	at net.javacrumbs.jsonunit.jsonpath.JsonPathAdapter.inPath(JsonPathAdapter.java:44)
	at net.javacrumbs.jsonunit.assertj.JsonAssert$ConfigurableJsonAssert.inPath(JsonAssert.java:417)
  1. Describe expected behavior

Test should pass; logging should be optional or bundled as a dependency.


The error can be resolved by modifying the Gradle configuration to:

integrationTest(JvmTestSuite) {
            dependencies {
                implementation 'com.fasterxml.jackson.core:jackson-databind:2.14.1'
                implementation 'net.javacrumbs.json-unit:json-unit-assertj:2.36.0'
                implementation 'org.slf4j:slf4j-api:2.0.6'
            }
        }

I also tested this on a "traditional" (non-JVM Suite configuration) Gradle project:

            dependencies {

... other dependencies

                testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.14.1'
                testImplementation 'net.javacrumbs.json-unit:json-unit-assertj:2.36.0'
            }

And the results, and the solution, was the same.

@lukas-krecan
Copy link
Owner

Thanks for reporting, I will look at it.

lukas-krecan added a commit that referenced this issue Jan 27, 2023
lukas-krecan added a commit that referenced this issue Jan 27, 2023
@lukas-krecan
Copy link
Owner

Fixed in 2.36.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants