<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: NICOLE LUCIANA RIOS COHAILA</title>
    <description>The latest articles on DEV Community by NICOLE LUCIANA RIOS COHAILA (@nicole_lucianarioscohai).</description>
    <link>https://dev.to/nicole_lucianarioscohai</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3602905%2F38375829-6703-47ef-9acc-298be18f6098.gif</url>
      <title>DEV Community: NICOLE LUCIANA RIOS COHAILA</title>
      <link>https://dev.to/nicole_lucianarioscohai</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nicole_lucianarioscohai"/>
    <language>en</language>
    <item>
      <title>Application of API Testing Frameworks in Java Introduction</title>
      <dc:creator>NICOLE LUCIANA RIOS COHAILA</dc:creator>
      <pubDate>Sun, 09 Nov 2025 04:38:56 +0000</pubDate>
      <link>https://dev.to/nicole_lucianarioscohai/application-of-api-testing-frameworks-in-java-introduction-40g6</link>
      <guid>https://dev.to/nicole_lucianarioscohai/application-of-api-testing-frameworks-in-java-introduction-40g6</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In modern software development, &lt;strong&gt;API testing frameworks&lt;/strong&gt; play a crucial role in ensuring that communication between services is reliable, consistent, and secure. &lt;strong&gt;APIs (Application Programming Interfaces)&lt;/strong&gt; are the backbone of microservices architectures, and their stability directly affects the performance of entire systems.&lt;/p&gt;

&lt;p&gt;Frameworks such as &lt;strong&gt;RestAssured&lt;/strong&gt;, &lt;strong&gt;Postman/Newman&lt;/strong&gt;, and &lt;strong&gt;Karate&lt;/strong&gt; allow developers to automate API testing and integrate it into &lt;strong&gt;Continuous Integration (CI/CD)&lt;/strong&gt; pipelines. This article focuses on the application of &lt;strong&gt;RestAssured&lt;/strong&gt; in Java for efficient API testing automation.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Why Use an API Testing Framework?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Manually testing APIs through tools like &lt;strong&gt;Postman&lt;/strong&gt; is suitable for initial exploration, but for large-scale systems, automated frameworks provide significant advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reusability:&lt;/strong&gt; Test cases can be modular and maintained over time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Integration:&lt;/strong&gt; Fits easily into CI/CD pipelines such as &lt;strong&gt;Jenkins&lt;/strong&gt; or &lt;strong&gt;GitHub Actions&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assertions:&lt;/strong&gt; Provides built-in methods to validate &lt;strong&gt;HTTP responses&lt;/strong&gt; and &lt;strong&gt;JSON data&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reporting:&lt;/strong&gt; Generates detailed reports for debugging and auditing.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;RestAssured: Overview&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;RestAssured&lt;/strong&gt; is a &lt;strong&gt;Java-based library&lt;/strong&gt; designed specifically for testing &lt;strong&gt;RESTful APIs&lt;/strong&gt;. It simplifies HTTP requests and allows developers to write readable, maintainable tests without complex setup.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Key Features&lt;/strong&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Supports all &lt;strong&gt;HTTP methods&lt;/strong&gt; (GET, POST, PUT, DELETE, PATCH)&lt;/li&gt;
&lt;li&gt;Compatible with &lt;strong&gt;JUnit&lt;/strong&gt; and &lt;strong&gt;TestNG&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Provides &lt;strong&gt;JSON&lt;/strong&gt; and &lt;strong&gt;XML&lt;/strong&gt; parsing for data validation&lt;/li&gt;
&lt;li&gt;Includes built-in support for &lt;strong&gt;authentication&lt;/strong&gt; and &lt;strong&gt;cookies&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Example: Testing a REST API with RestAssured&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Below is a real-world example of how to test a sample API endpoint using &lt;strong&gt;RestAssured&lt;/strong&gt; and &lt;strong&gt;JUnit 5&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;io.restassured.RestAssured&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;io.restassured.response.Response&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.jupiter.api.Test&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;static&lt;/span&gt; &lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;restassured&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;RestAssured&lt;/span&gt;&lt;span class="o"&gt;.*;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;static&lt;/span&gt; &lt;span class="n"&gt;org&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hamcrest&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Matchers&lt;/span&gt;&lt;span class="o"&gt;.*;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserApiTest&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Test&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testGetUserById&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;RestAssured&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;baseURI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://jsonplaceholder.typicode.com"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="n"&gt;given&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;get&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/users/1"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;then&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;equalTo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"username"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;notNullValue&lt;/span&gt;&lt;span class="o"&gt;())&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;log&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;all&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@Test&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;testCreateUser&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;RestAssured&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;baseURI&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"https://jsonplaceholder.typicode.com"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;newUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{ \"name\": \"John Doe\", \"username\": \"johndoe\", \"email\": \"john@example.com\" }"&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

        &lt;span class="n"&gt;given&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;header&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Content-Type"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"application/json"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;newUser&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;when&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;post&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/users"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;then&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;201&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"name"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;equalTo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"John Doe"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"email"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;equalTo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"john@example.com"&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;log&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;all&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  &lt;strong&gt;Explanation of the Code&lt;/strong&gt;
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Base URI:&lt;/strong&gt; Defines the root of the API (&lt;code&gt;jsonplaceholder.typicode.com&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;given() / when() / then():&lt;/strong&gt; Core &lt;strong&gt;RestAssured&lt;/strong&gt; syntax inspired by &lt;strong&gt;Behavior-Driven Development (BDD)&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Assertions:&lt;/strong&gt; Validate the &lt;strong&gt;HTTP status code&lt;/strong&gt; and specific &lt;strong&gt;JSON fields&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Logging:&lt;/strong&gt; The method &lt;code&gt;.log().all()&lt;/code&gt; outputs detailed request and response data for debugging.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This example demonstrates how to validate both &lt;strong&gt;GET&lt;/strong&gt; and &lt;strong&gt;POST&lt;/strong&gt; endpoints with minimal boilerplate code.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Integrating with CI/CD&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;RestAssured&lt;/strong&gt; tests can be integrated into a &lt;strong&gt;Maven&lt;/strong&gt; or &lt;strong&gt;Gradle&lt;/strong&gt; project and executed automatically through a &lt;strong&gt;CI/CD pipeline&lt;/strong&gt;.&lt;br&gt;
For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In &lt;strong&gt;Jenkins&lt;/strong&gt;, add a build step that runs &lt;code&gt;mvn test&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Test reports can be exported using the &lt;strong&gt;Surefire&lt;/strong&gt; plugin or integrated with tools like &lt;strong&gt;Allure Report&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This automation ensures that every new API deployment is validated before reaching production, improving &lt;strong&gt;quality&lt;/strong&gt; and &lt;strong&gt;reliability&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;Conclusion&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The use of frameworks like &lt;strong&gt;RestAssured&lt;/strong&gt; empowers teams to automate and scale their &lt;strong&gt;API testing&lt;/strong&gt; process. By integrating automated tests into &lt;strong&gt;CI/CD workflows&lt;/strong&gt;, developers can identify defects early, improve code reliability, and accelerate software delivery.&lt;/p&gt;

&lt;p&gt;As APIs continue to evolve in complexity, adopting robust testing frameworks becomes not just an advantage but a &lt;strong&gt;necessity&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;strong&gt;References&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://rest-assured.io/" rel="noopener noreferrer"&gt;&lt;strong&gt;RestAssured Documentation&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/@omerkapi/the-top-10-api-testing-tools-in-2020-detailed-analysis-3e6c91e53c6d" rel="noopener noreferrer"&gt;&lt;strong&gt;Top 10 API Testing Tools in 2020 | Medium&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://junit.org/junit5/docs/current/user-guide/" rel="noopener noreferrer"&gt;&lt;strong&gt;JUnit 5 User Guide&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>api</category>
      <category>testing</category>
      <category>java</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
