Getting started with Rest-Assured for REST-Api Testing



  • 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:

    @morde public void testGetSingleUser() {
          expect().
            statusCode(200).
            body(
              "email", equals("test@hascode.com"),
              "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.



  • 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



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2