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