Hi,
I had the following issue with Maven 2 getting Rest-assured to work. I
am somewhat of a Maven newbie so it took me a while to figure it out.
For any command, such as:
given()
.parameters("emailId", "
bademai...@test.com", "password",
"badpassword", "imei", imei, "partnerCode", partnerCode)
.expect().body("errors", equalTo("Unable to validate account"))
.when().post(accountsContext);
I got an exception (always the same one):
java.lang.NoSuchFieldError: tokenTypeToASTClassMap
at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.buildTokenTypeASTClassMap(GroovyRecognizer.java:
14165)
at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.<init>(GroovyRecognizer.java:
460)
at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.<init>(GroovyRecognizer.java:
465)
at
org.codehaus.groovy.antlr.parser.GroovyRecognizer.make(GroovyRecognizer.java:
222)
....
at
com.jayway.restassured.assertion.JSONAssertion.getResult(JSONAssertion.groovy:
33)
... (much more...)
Using this as dependency:
<dependency>
<groupId>com.jayway.restassured</groupId>
<artifactId>rest-assured</artifactId>
<version>1.2.1</version>
<scope>test</scope>
</dependency>
The solution was to make sure that this dependency appears FIRST in
the pom.xml, as suggested by Johan. If your project uses some of the
same libraries that rest-assured uses, it could cause conflicts if
there are different versions. I also had to include this right after
the above dependency:
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.1</version>
<scope>test</scope>
</dependency>
Maven was for some reason unable to resolve this one on its own. Hope
that helps if anyone encounters this problem.