While debugging a NoSuchMethodError with @yegeniy and @iantabolt, I wanted to offer a suggestion to use the mockito-core library rather than mockito-all. mockito-all includes Hamcrest classes, which can clash with Hamcrest classes pulled in as a transitive dependency of JUnit 4.11+ (see below dependency tree for JUnit 4.12).
Specifically, cukes-rest version 0.2.13 uses mockito-all version 1.10.8, which includes old Hamcrest classes (I think from 1.1). Notice that the below 1.10.8 version of mockito-all's Hamcrest Matcher class is missing the describeMismatch method.
This manifests itself in the following NoSuchMethodError exception when a test fails using JUnit 4.11+.
Scenario: currentTeam hydration # features/person.feature:2
Given queryParam "hydrate" is "currentTeam" # GivenSteps.query_Param(String,String)
When the client performs GET request on /v1/people/8471675 # WhenSteps.perform_Http_Request(String,String)
Then response contains property "people[0].currentTeam.teamName" with value "Penguins" # ThenSteps.response_Body_Contains_Property(String,String)
java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Description;)V
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
at org.junit.Assert.assertThat(Assert.java:956)
at org.junit.Assert.assertThat(Assert.java:923)
at lv.ctco.cukesrest.internal.AssertionFacadeImpl.bodyContainsPathWithValue(AssertionFacadeImpl.java:103)
at lv.ctco.cukesrest.internal.switches.SwitchedByInterceptor.invoke(SwitchedByInterceptor.java:33)
at lv.ctco.cukesrest.internal.context.InflateContextInterceptor.invoke(InflateContextInterceptor.java:30)
at lv.ctco.cukesrest.api.ThenSteps.response_Body_Contains_Property(ThenSteps.java:64)
at ✽.Then response contains property "people[0].currentTeam.teamName" with value "Penguins"(features/person.feature:5)
When fixing the dependency, we get a much more helpful error message.
Scenario: currentTeam hydration # features/person.feature:2
Given queryParam "hydrate" is "currentTeam" # GivenSteps.query_Param(String,String)
When the client performs GET request on /v1/people/8471675 # WhenSteps.perform_Http_Request(String,String)
Then response contains property "people[0].currentTeam.teamName" with value "Penguins" # ThenSteps.response_Body_Contains_Property(String,String)
java.lang.AssertionError:
Expected: Path people[0].currentTeam.teamName contains equal to ignoring type Penguins
but: was null
at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:956)
at org.junit.Assert.assertThat(Assert.java:923)
at lv.ctco.cukesrest.internal.AssertionFacadeImpl.bodyContainsPathWithValue(AssertionFacadeImpl.java:103)
at lv.ctco.cukesrest.internal.switches.SwitchedByInterceptor.invoke(SwitchedByInterceptor.java:33)
at lv.ctco.cukesrest.internal.context.InflateContextInterceptor.invoke(InflateContextInterceptor.java:30)
at lv.ctco.cukesrest.api.ThenSteps.response_Body_Contains_Property(ThenSteps.java:64)
at ✽.Then response contains property "people[0].currentTeam.teamName" with value "Penguins"(features/person.feature:5)
Hello again!
While debugging a
NoSuchMethodError
with @yegeniy and @iantabolt, I wanted to offer a suggestion to use themockito-core
library rather thanmockito-all
.mockito-all
includes Hamcrest classes, which can clash with Hamcrest classes pulled in as a transitive dependency of JUnit 4.11+ (see below dependency tree for JUnit 4.12).Specifically,
cukes-rest
version0.2.13
usesmockito-all
version1.10.8
, which includes old Hamcrest classes (I think from 1.1). Notice that the below1.10.8
version ofmockito-all
's HamcrestMatcher
class is missing thedescribeMismatch
method.This manifests itself in the following
NoSuchMethodError
exception when a test fails using JUnit 4.11+.When fixing the dependency, we get a much more helpful error message.