{"id":13313976,"url":"https://github.com/wildec2/java-rest-assured-framework","last_synced_at":"2026-05-09T15:19:53.064Z","repository":{"id":36994942,"uuid":"447131507","full_name":"wildec2/java-rest-assured-framework","owner":"wildec2","description":"This is a java and rest-assured based test automation framework for the testing of web api's/microservices.","archived":false,"fork":false,"pushed_at":"2023-09-08T07:07:07.000Z","size":88,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-02T15:35:11.282Z","etag":null,"topics":["allure","allure-report","api-testing","api-testing-framework","gradle","java","jenkins","rest-assured","test-automation","testng"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wildec2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-12T08:16:01.000Z","updated_at":"2022-01-18T11:07:27.000Z","dependencies_parsed_at":"2025-02-02T15:43:08.406Z","dependency_job_id":null,"html_url":"https://github.com/wildec2/java-rest-assured-framework","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildec2%2Fjava-rest-assured-framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildec2%2Fjava-rest-assured-framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildec2%2Fjava-rest-assured-framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wildec2%2Fjava-rest-assured-framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wildec2","download_url":"https://codeload.github.com/wildec2/java-rest-assured-framework/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246052126,"owners_count":20715974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["allure","allure-report","api-testing","api-testing-framework","gradle","java","jenkins","rest-assured","test-automation","testng"],"created_at":"2024-07-29T18:09:52.576Z","updated_at":"2026-05-09T15:19:52.990Z","avatar_url":"https://github.com/wildec2.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Overview\nThis is a java and [rest-assured](https://rest-assured.io/) based test automation framework for the testing of web api's/microservices.\nThe build tool is [Gradle](https://gradle.org/) and the [testng](https://testng.org/doc/) test automation framework is used for specifying, arranging and running the tests. \n[Allure](https://docs.qameta.io/allure/) reporting is used to give a detailed overview of test result including steps with attached cURLs and response/request payloads. \nThere's also a Jenkins set-up included to get the tests running in a pipeline.\n\n## Setup\nThis will work straight out-of-the-box once your java setup is ok. Java 17 and Gradle 7.1 were used when building and testing. \nThere's a gradle wrapper included, so you don't have to install gradle. Just use gradlew(or ./gradlew) rather than gradle when running commands. \nClone the repo, open in IntelliJ, build and run the tests.\n\n## Running Tests\nYou can run your tests using intelliJ straight away.\nOr you can run with gradle and view the Allure report.\n```\ngradle test\n```\nIf you want to view the Allure report after:\n```\ngradle allureServe\n```\nThis will fire up the allure server and open the results in your default browser.\n\n# How it Works\nSeveral things are tied together to allow us to make requests against out api under test, serialize payloads, deserialize responses,\ndefine our tests and report the results. Each are outlined here and how they work together to create the conditions under which the tests are run.\n\n## Gradle\n**Plugins**\n\nApplying the following plugins to the project allows us to extend the project’s capabilities.\n```\nplugins {\n    id 'java'\n    id 'io.qameta.allure' version '2.9.6'\n    id 'io.freefair.lombok' version '6.3.0'\n}\n```\n1. The java plugin adds Java compilation along with testing and bundling capabilities to the project.\n2. The allure plugin is for building Allure reports for TestNG(or other test frameworks such as JUnit or Spock).\n3. The lombok plugin is for annotation processing and compiling.\n\n\n**Compatibility Options**\n\n```\nsourceCompatibility = JavaVersion.VERSION_17\ntargetCompatibility = JavaVersion.VERSION_17\n```\n\n* sourceCompatibility is Java version compatibility to use when compiling Java source.\n* targetCompatibility is Java version to generate classes for.\n\n\n**Repositories**\n\nThe repositories for which our project resolves its dependencies.\n```\nrepositories {\n    mavenCentral()\n    google()\n}\n```\nSee the [gradle documentation](https://docs.gradle.org/current/userguide/declaring_repositories.html) for more information around other repositories \nand setting up custom repositories.\n\n\n**Dependencies**\n\nThe things that supports in building our project.\n```\ndependencies {\n    implementation(\n            'io.rest-assured:rest-assured:4.4.0',\n            'com.fasterxml.jackson.core:jackson-databind:2.13.1',\n            'com.fasterxml.jackson.core:jackson-core:2.13.1',\n            'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.1',\n            'org.hamcrest:hamcrest:2.2',\n            'io.qameta.allure:allure-testng:2.17.2',\n            'io.qameta.allure:allure-rest-assured:2.17.2'\n    )\n    testImplementation(\n            'org.testng:testng:7.5'\n    )\n}\n```\n1. rest-assured: for all rest-assured commands.\n2. jackson: for serialisation and deserialization.\n3. hamcrest: for the hamcrest matchers used in our assertions.\n4. allure: allure report and testng configuration.\n5. testng: for use of testng framework as our test runner.\n\n\n**Allure**\n\nFor configuring allure. Here we are only pass the version parameter but there are many parameters for configuration.\n```\nallure {\n    version = '2.17.2'\n}\n```\n\n**Test**\n\nThe task to run our tests and specifying the test configuration.\n\n```\ntest {\n    systemProperties System.getProperties()\n    systemProperties.remove(\"java.endorsed.dirs\")\n    scanForTestClasses = false\n    useTestNG() {\n        useDefaultListeners = true\n    }\n    testLogging.showStandardStreams = true\n}\n```\n\n\n## Rest Assured\nBaseApi.java specifies how are the requests are made using Rest-Assureds RequestSpecification.\n```\nRequestSpecification requestSpecification = new RequestSpecBuilder()\n            .setBaseUri(BASE_URL)\n            .setContentType(ContentType.JSON)\n            .addFilter(new AllureRestAssured())\n            .build();\n```\n\nHere we specify the BASE_URL to be used by all our requests. This is a system variable that can be passed in when we build the project, so we can run on any environment.\n```\n./gradlew test -DbaseUrl=http://www.MY_URL.com/\n```\nOur content type is always set to JSON. And we add a filter that enables requests/responses to be logged in our allure report.\nWe then create a RequestSpecification object and say we'll use the RequestSpecification outlined above thus alleviating the need for rest-assured given() method to be littered throughout our tests.\n```\nprotected RequestSpecification requestSender = RestAssured.given(requestSpecification);\n```\nI try to avoid using the given(), when() and then rest assured methods in my tests as I don't think it's readable. Every api class that we create to make requests with now extent this so our code will be much cleaner.\n```\npublic Response postBooking(Booking payload) {\n   return requestSender.body(payload)\n                       .post(PATH);\n}\n```\n\nSee RequestSpecification documentation for more details.\n\nThe payloads for requests are POJOs. As are our request responses. \n```\n@JsonProperty\nprivate int roomid;\n```\nThis is where jackson is used to serialize/deserialize respectively. Ensure the variable name matches that which is required in the payload or seen in the api response.\nThere are ways to rename to what you wish. To deserialize we use the rest-assured 'as' function and pass in the desired POJO class.\n```\nBookingResponse createdBookingResponse = bookingApi.postBooking(payload).as(BookingResponse.class);\n```\nThis allows us to work with the java defined in the class. Typically, the getters. In the response POJOs note the use of the lombok '@Getter' annotation.\nThis is used, so we don't have to write getter boilerplate code. 'createdBookingResponse.' and you'll see all the getter.\n\n## TestNG\nThe tests live in the test module. Every class of tests will extend the BaseTest.java class which will house items common to all.\nTestNG is the test runner. Simply create a method in one of the test classes and annotate with @Test the TestNG library.\n```\n@Test(description = \"get bookings 200s\")\npublic void getBookingShouldReturn200(){\n   Response response = bookingApi.getBookings();\n\n   assertThat(\"Incorrect response code\", response.getStatusCode(), is(200));\n}\n```\nHamcrest matchers and assertions are then used to compare actual and expected results.\n\n## Allure\nEach request is annotated, so we'll have a readable description in our final allure report.\n```\n@Step(\"get booking request\")\n```\nAs mentioned, the allure filter is added to the request spec in BaseApi.java. Now every rest-assured request, response and cURL will appear under the step.\n```\n.addFilter(new AllureRestAssured())\n```\nTo view the final report run 'gradle allureServe'\n\n## Jenkins\nset up details","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwildec2%2Fjava-rest-assured-framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwildec2%2Fjava-rest-assured-framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwildec2%2Fjava-rest-assured-framework/lists"}