2

I am new to REST-Api testing. i am getting started with Rest-Assured for Rest-Api testing. i am having an issue in my first ever testcase.

The code is as follows:

@Test
public void testGetSingleUser() {
      expect().
        statusCode(200).
        body(
          "email", equals("[email protected]"),
          "firstName", equals("Tim"),
          "lastName", equals("Testerman"),
          "id", equals("1")).
        when().
        get("/service/single-user");
}

In this code the expect(). command is not working. I need to fix this issue quickly and move on.

1

1 Answer 1

3

Updated Answer

You have to import the RestAssured class incl. method as static.

import static com.jayway.restassured.RestAssured.expect;

Or you call the method on this way:

RestAssured.expect()

Useful Links

5
  • equalsTo() is not working. equals() in working fine. The problem is that my expect() command is not working. I am using eclipse with rest-assured jar included. Oct 9, 2014 at 7:20
  • @JarreeArhamShahid Can you put the exception into your question, to be more specific? Thank you.
    – Twaldigas
    Oct 9, 2014 at 7:21
  • java.lang.Error: Unresolved compilation problem: The method expect() is undefined for the type RestTest Oct 9, 2014 at 7:33
  • This is the failure trace. Its not working because the expect() in the code above has an error. Do i need to include any jars to make it work? Oct 9, 2014 at 7:34
  • @JarreeArhamShahid Updated the answer.
    – Twaldigas
    Oct 9, 2014 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.