Skip to main content

Rest Assured

Day 2: Setting up Rest Assured

What is Rest Assured?

Rest Assured is a popular Java-based library used for testing RESTful web services. It is widely used in the software industry for automating API testing in a simple and efficient manner. Rest Assured makes testing API endpoints easier by providing a simple and intuitive DSL (Domain Specific Language) that enables developers to write automated tests in a readable and concise manner.

Some of the key features of Rest Assured include:

  • Fluent API: Rest Assured provides a fluent API that allows developers to write concise and readable tests.
  • Request specification: Developers can set up a request specification that defines the request method, headers, cookies, and query parameters.
  • Response specification: Developers can also define a response specification that specifies the expected response code, headers, and body.
  • Validation: Rest Assured provides a range of validation methods that enable developers to check the response status, headers, and body.
  • Support for different data formats: Rest Assured supports JSON, XML, and plain text response formats.

Day 1: Introduction to Rest Assured

  • Learn about what Rest Assured is, and what it can be used for
  • Familiarize yourself with some basic concepts such as HTTP methods and request/response objects

Day 2: Setting up Rest Assured

  • Install Rest Assured and its dependencies
  • Set up your development environment

Day 3: Writing your first test with Rest Assured

  • Create a simple test that sends a request to an API endpoint and verifies the response
  • Learn about basic Rest Assured syntax and assertions

Day 4: Understanding HTTP methods

  • Learn about HTTP methods such as GET, POST, PUT, DELETE and how to use them in Rest Assured
  • Understand how to set up request headers and query parameters

Day 5: Working with JSON responses

  • Learn how to work with JSON responses using Rest Assured
  • Use methods such as JsonPath and Matchers to parse and validate JSON responses

Day 6: Working with XML responses

  • Learn how to work with XML responses using Rest Assured
  • Use methods such as XPath and Matchers to parse and validate XML responses

Day 7: Writing data-driven tests

  • Learn how to write data-driven tests using Rest Assured
  • Use techniques such as parameterization and iteration to test different scenarios

Day 8: Understanding authentication in Rest Assured

  • Learn how to authenticate requests using Rest Assured
  • Use techniques such as basic authentication, OAuth and JWT authentication

Day 9: Handling cookies and sessions

  • Learn how to handle cookies and sessions in Rest Assured
  • Use techniques such as capturing and reusing cookies to simulate user sessions

Day 10: Working with response headers

  • Learn how to work with response headers using Rest Assured
  • Use methods such as Header and Headers to validate response headers

Day 11: Handling timeouts and error responses

  • Learn how to handle timeouts and error responses using Rest Assured
  • Use techniques such as setting up timeouts and handling error responses

Day 12: Working with multipart requests

  • Learn how to work with multipart requests using Rest Assured
  • Use techniques such as sending files and images in a multipart request

Remaining Topics coming Soon.....



Comments

Popular posts from this blog

How to integrate Autoit with selenium

For handling Dialog boxes which are not web based, Then Autoit is the best Tool to handle this These are the following code should written in Selenium Selenium Code: try { String[] commands = new String[] {}; commands = new String[] { "Path" }; // location of Autoit EXE file Runtime.getRuntime().exec(commands); } catch (IOException e) { } Autoit code: if WinWaitActive("File Upload") Then ;MsgBox(2,"window found","Found the window") WinActivate("File upload") Send("!n") Sleep(5000) Send("File path") SEND("{ENTER}") ;location of the file you want to a to the form and submit ;Send("!O") Else MsgBox(1,"TimeOut","Timed out") EndIf Here we need to create a Exe file for the Autoit script and that path should be mentioned in selenium code.

Reflection API

The Reflection API allows Java code to examine classes and objects at run time.The new reflection classes allow you to call another class's methods dynamically at run time. With the reflection classes, you can also examine an instance's fields and change the fields' contents. The Reflection API consists of the java.lang.Class class and the java.lang.reflect classes: Field, Method, Constructor, Array, and Modifier. Example program: import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; // calling method whose name we store in a variable public class ReflectionAPI { public static void main(String[] args) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException { String x="sampleTest"; //String meth=read name from xls file Method method= ReflectionAPI.class.getMethod(x, String.class); method.invoke(method, "welcome"); System.out.

Collection API

CollectionAPI: The Java Collections API's provide Java developers with a set of classes and interfaces that makes it easier to handle collections of objects. In a sense Collection's works a bit like arrays, except their size can change dynamically, and they have more advanced behaviour than arrays. Example program: import java.util.ArrayList; import java.util.Hashtable; public class CollectionAPI { /** * @param args */ public static void main(String[] args) { int names[] = new int[5]; ArrayList list = new ArrayList (); list.add("Ramu");//0 list.add("Venu");//1 list.add("Raju");//2 System.out.println(list.size()); for(int i =0; i<=list.size(); i++) { System.out.println(list.get(i)); } // key - value // key - unique Hashtable table = new Hashtable (); table.put("name", "Hyderabad"); table.put("place", "Mumbai"); table.put("na