Skip to content

testingtrail/restassured_cucumber-testng

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Project Details

Json Fake server

Authorization with Bearer Token

Within the jsonServer folder there are some package.json and javascript files that creates authorization within the JSON fake server, with the purpose of testing token authentication within this project.

  • Instead of 'json-server db.json' use 'npm install' the first time and then 'npm run start-auth' each time you want to run it.
  • That will start the authorization code that has been created

Deserializing JSON to POJO

We have some pojo classes called Address.java, Location.java, Post.java that takes Json responses and transform it into classes, then we can use it as: var posts = response.getBody().as(Posts.class);

Json Schema matcher

There is also a schema matcher and the idea is to validate the json response against the one expected.

  • You crete the post.json in the target/classes folder as this will be read from there in execution.
  • You need the dependency called 'json-schema-validator'
  • In method iShouldSeeTheAuthorNameAsWithJSONValidation
    • Add the library: import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath;
    • Then you call the static method matchesJsonSchemaInClasspath
  • Now it will assert the schema against the one expected when you run this scenario.

Changing libraries to generic ones

The work will be done over 'RestAssuredExtension.java' file

  • Create a new 'RestAssuredExtensionV2.java' file
  • Create a new 'APIConstants.java' file

About

sample project using restAssured, cucumber and testNG

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published