0% found this document useful (0 votes)
9 views6 pages

Maven Project Setup for API Testing

The document outlines the steps to create a Maven project for REST API testing using RestAssured. It includes instructions for setting up the pom.xml file with necessary dependencies, creating a test package and class, and writing a basic GET request test. The final output mentions developing a project in Trello software for a banking website.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Maven Project Setup for API Testing

The document outlines the steps to create a Maven project for REST API testing using RestAssured. It includes instructions for setting up the pom.xml file with necessary dependencies, creating a test package and class, and writing a basic GET request test. The final output mentions developing a project in Trello software for a banking website.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Practical 3

1. Crate a new maven project

2. Open [Link] and paste it


<modelVersion>4.0.0</modelVersion>

<groupId>[Link]</groupId>
<artifactId>restassured-api-testing1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>restassured-api-testing1</name>
<url>[Link]

<properties>
<[Link]>UTF-8</[Link]>
</properties>

<dependencies>
<dependency>
<groupId>[Link]-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>5.3.0</version> <!-- Check for the latest version -->
<scope>test</scope>
</dependency>

<!-- You can also add other libraries like JSON, Hamcrest if required -->
<dependency>
<groupId>[Link]</groupId>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>[Link]</groupId>
<artifactId>json</artifactId>
<version>20210307</version>

</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version> <!-- JUnit 4 version -->
<scope>test</scope>
</dependency>

</dependencies>
</project>

3. Now right click on src/test/java and click on new and select the pakages
Name the package as [Link]
4. Now right click on [Link] and click on new and select the class
Name the class as restassuredgettest

5. Paste this code and run it


// Basic Request Test
import [Link];
import [Link];
import [Link];

import static [Link];


import static [Link];

public class restassuredgettest {


@Test
public void testGetRequest() {

// Base URI of the API


[Link] = "[Link]

// Send a GET request and capture the response


Response response = given()
.when()
.get("/posts/1");
// Extract and print the status code
int statusCode = [Link]();
[Link]("Status code: " + statusCode);

// Validate the response


[Link]()
.statusCode(200) // Validate HTTP response status code
.body("userId", equalTo(1)) // Validate JSON response body
.body("id", equalTo(1))
.body("title", equalTo("sunt aut facere repellat provident occaecati excepturi optio
reprehenderit"));
}
}

Final output -

Skill 3- develop a project intrello software for banking website

You might also like