Posts

Showing posts with the label rest assured api testing

Validate JSON Schema using Rest Assured

Image
JSON Schema is a powerful tool for validating the structure of JSON data or your JSON Response. JSON Schema itself is written in JSON. It is data itself, not a computer program. It’s just a declarative format for “describing the structure of other data”.  The JSON document being validated or described we call the   instance , and the document containing the description is called the   schema . JSON Schema validation is done to check whether the response received is correct or is structured according to the defined schema for your project.  Let's loo k at an example of JSON Schema validation using Rest Assured. Here we are making use of Google Search API that we studied in  Testing GET Requests and their Responses using Rest Assured . I would highly recommend reading previous posts before reading this one. Lets us create a JSON File where we will define the JSON Schema for our response ( JSON Schema of a Response that we will get when...

Verifying File Download using Rest Assured.

Image
In the previous post, we studied about f inding broken links using Rest Assured . In this post, we will learn about verifying file download using Rest Assured. We will first download the file for which we will perform the verification of size. We will download  rest-assured-3.0.5-dist.zip   file   from Rest Assured Download   Section . We will save the file inside our eclipse project.  Now let us look at an example of verifying file download using Rest Assured: import org.testng.Assert ; import org.testng.annotations.Test ; import java.io.File ; import static io . restassured . RestAssured .*; public class GetRequestTest { @Test public void verifyFileDownload () { int fileSize ; File filePath = new File ( System . getProperty ( "user.dir" )+ "/resources/rest-assured-3.0.5-dist.zip" ); fileSize = ( int ) filePath . length (); System . out . println ( "The actual value is " + f...

Popular posts from this blog

Extracting an XML Response with Rest-Assured