{"id":26674164,"url":"https://github.com/mideo/api-test-kit","last_synced_at":"2025-07-24T20:38:18.089Z","repository":{"id":57721515,"uuid":"103111115","full_name":"MideO/api-test-kit","owner":"MideO","description":"Test library for quick bootstrapping API Acceptance/Integration and Performance tests base classes backed with JUnit, Wiremock, Atam4J, and Gatling.","archived":false,"fork":false,"pushed_at":"2017-11-27T20:29:13.000Z","size":49,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-26T02:17:35.783Z","etag":null,"topics":["api-testing","atam4j","gatling","javascript","junit","rest-assured","scala","wiremock"],"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/MideO.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}},"created_at":"2017-09-11T08:39:11.000Z","updated_at":"2017-10-20T14:01:20.000Z","dependencies_parsed_at":"2022-09-26T21:41:19.690Z","dependency_job_id":null,"html_url":"https://github.com/MideO/api-test-kit","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MideO%2Fapi-test-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MideO%2Fapi-test-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MideO%2Fapi-test-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MideO%2Fapi-test-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MideO","download_url":"https://codeload.github.com/MideO/api-test-kit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245573892,"owners_count":20637674,"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":["api-testing","atam4j","gatling","javascript","junit","rest-assured","scala","wiremock"],"created_at":"2025-03-26T02:17:39.521Z","updated_at":"2025-03-26T02:17:40.078Z","avatar_url":"https://github.com/MideO.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"## api-test-kit \n\n[![Build Status](https://travis-ci.org/MideO/api-test-kit.svg?branch=master)](https://travis-ci.org/MideO/api-test-kit)\n\n### Modules\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mideo/api-test-kit_2.11/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.mideo%22%20a%3A%22api-test-kit_2.11%22) api-test-kit\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mideo/api-test-kit-api_2.11/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.mideo%22%20a%3A%22api-test-kit-api_2.11%22) api-test-kit-api\n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mideo/api-test-kit-performance_2.11/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.mideo%22%20a%3A%22api-test-kit-performance_2.11%22) api-test-kit-performance \t  \n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mideo/api-test-kit-core_2.11/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.mideo%22%20a%3A%22api-test-kit-core_2.11%22) api-test-kit-core \t  \n\n[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mideo/api-test-kit-monitoring_2.11/badge.svg)](http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.github.mideo%22%20a%3A%22api-test-kit-monitoring_2.11%22) api-test-kit-monitoring \n\nTest library for quick bootstrapping API Acceptance/Integration and Performance tests base classes backed with JUnit, Wiremock, Atam4J, and Gatling. \n\nFor more information on test tools see:\n \n* [JUnit](http://junit.org)\n* [Rest-Assured](http://rest-assured.io/)\n* [Wiremock](http://wiremock.org)\n* [Atam4J](https://github.com/atam4j/atam4j)\n* [Gatling](http://gatling.io)\n\n\n#### Java Utilities\n* RestAssuredSpecFactory - Create rest-assured request spec with all wapi required headers\n ```java\n public class Example {\n         public static void main(String[] args) throws Exception {\n             RestAssuredSpecFactory.givenARequestSpecificationWithAllRequiredHeaders()\n                    .when()\n                    .post(\"http://exmaple.com\")\n                    .then().statusCode(200);\n        \n     }\n }\n \n ```\n\n* AtamApplication - Acceptance Test as Monitors bootstrap\n```java\npublic class ExampleAtamApplication extends Atam4jMainApplication {\n        public static void main(String[] args) throws Exception {\n        if (args == null || args.length == 0) {\n            args = new String[]{\"server\", getAtam4JConfigFile()};\n        }\n        new ExampleAtamApplication().run(args);\n    }\n}\n\n\n```\n* ApiTest - Bootstrap api tests by starting and shutting down the test application \n```java\nclass ExampleApiTest extends ApiTest {\n\n    @Override\n    void startApplication() {\n        Spark.start();\n    }\n\n    @Override\n    void stopApplication() {\n        Spark.stop();\n    }\n\n    @Override\n    void loadTestApplicationProperties() {\n        try {\n            properties.load(getClass().getClassLoader().getResourceAsStream(\"test.properties\"));\n        } catch (IOException | URISyntaxException e) {\n            e.printStackTrace();\n        }\n    }\n}\n\n```\n* WiremockBasedApiTest - Bootstrap api tests by starting and shutting down the test application and wiremock\n```java\nclass ExampleWiremockBasedApiTest extends WireMockBasedApiTest {\n\n    @Override\n    void startApplication() {\n        Spark.start();\n    }\n\n    @Override\n    void stopApplication() {\n        Spark.stop();\n    }\n\n    @Override\n    void loadTestApplicationProperties() {\n        try {\n            properties.load(getClass().getClassLoader().getResourceAsStream(\"test.properties\"));\n        } catch (IOException | URISyntaxException e) {\n            e.printStackTrace();\n        }\n    }\n}\n\n```\n* JsonParser - quickly serialize/deserialize json backed by jackson\n```java\n    public class DummyExample {\n           \n        static class Dummy {\n    \n    \n            public String getName() {\n                return name;\n            }\n    \n            private String name;\n    \n            public void setName(String name) {\n                this.name = name;\n            }\n    \n        }\n\n        public static void main(String[] args) {\n        \n            Dummy d = JsonParser.deserialize(\"{\\\"name\\\":\\\"Dummy\\\"}\", Dummy.class);\n            String payload = JsonParser.serialize(ImmutableMap.of(\"abc\", \"123\"));\n        }\n    }\n```\n  \n * StubBuilder - wiremock backed stubbing\n ```java\n public class Example {\n          public static void main(String[] args) throws Exception {\n              StubBuilder stubServer = new StubBuilder().startWireMock();\n              \n              //stubbing\n              stubServer.givenWiremockWillReturnCode(200);\n              \n              //set wiremock as proxy and record conversation with a third party service for future use\n              StubRecorder recorder = stubBuilder.recorder(\"https://example.com\", 443).record(\n                              () -\u003e requestSpecification\n                                      .when()\n                                      .get(\"/blueRed\")\n                                      .then()\n                                      .statusCode(404)\n                      );\n              \n                      \n              List\u003cStubMapping\u003e mappings = recorder.saveRecording().then().getRecording();\n              \n      }\n  }\n\n```\n\n#### Scala Utilities\n* PerformanceTest - Base Performance Test Class\n* LocalPerformanceTest - Performance Test Class bootstrapping of start and shutdown local test application\n* MockedLocalPerformanceTest - Performance Test Class bootstrapping of start and shutdown local test application and Wiremock\n* PerformanceTestConfig - Performance Test Config\n\n```scala\nimport com.github.mideo.apitestkit.AsciiArt\nimport io.gatling.core.Predef.{atOnceUsers, scenario}\nimport io.gatling.core.controller.inject.InjectionStep\nimport io.gatling.core.structure.{PopulationBuilder, ScenarioBuilder}\nimport io.gatling.http.Predef._\nimport io.gatling.core.Predef._\nimport org.junit.runner.RunWith\n\n\n\n\nobject FakeScenario extends TestScenario {\n  override def scenarioBuilder(business: String, userName: String): ScenarioBuilder = {\n    scenario(s\"Fake Scenario $business\")\n      .exec(http(\"fake request\").get(\"/\"))\n  }\n}\n\nclass FakeLocalPerformanceTest\n  extends LocalPerformanceTest{\n  AsciiArt.draw(\"TestLibs\")\n  override val testScenarios: List[TestScenario] = List(FakeScenario)\n  override val simulations: List[PopulationBuilder] = testScenarios map { _.scenarioBuilder(\"test\", \"simulation\").inject(injection) }\n\n  override def injection: InjectionStep = atOnceUsers(1)\n  doSetUp()\n\n  override def startApplication(): Unit = {}\n\n  override def stopApplication(): Unit = {}\n}\n\nclass FakeMockedPerformanceTest\n  extends LocalPerformanceTest{\n  AsciiArt.draw(\"TestLibs\")\n  override val testScenarios: List[TestScenario] = List(FakeScenario)\n  override val simulations: List[PopulationBuilder] = testScenarios map { _.scenarioBuilder(\"test\", \"simulation\").inject(injection) }\n  \n  ScalaStubBuilder.givenWiremockWillReturnCode(200)\n  \n  override def injection: InjectionStep = atOnceUsers(1)\n  doSetUp()\n\n  override def startApplication(): Unit = {}\n\n  override def stopApplication(): Unit = {}\n}\n\nclass FakePerformanceTest\n  extends PerformanceTest{\n  AsciiArt.draw(\"TestLibs\")\n  override val testScenarios: List[TestScenario] = List(FakeScenario)\n  override val simulations: List[PopulationBuilder] = testScenarios map { _.scenarioBuilder(\"test\", \"simulation\").inject(injection) }\n\n  override def injection: InjectionStep = atOnceUsers(1)\n  doSetUp()\n}\n\n\nobject FakeRunner {\n  def main(args:Array[String]): Unit ={\n    \n    PerformanceTestConfig.forUrl(\"performanceTest.url\")\n        .withSuccessfulRequestPercentage(99)\n      .withRequestPerSecond(5)\n    \n    GatlingTestRunner.forSimulationClass(classOf[FakePerformanceTest].getName)\n      .fromSourceDirectory(\"src/test\")\n      .saveResultDirectoryTo(\"build/reports/performanceTest\")\n      .run\n    \n  } \n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmideo%2Fapi-test-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmideo%2Fapi-test-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmideo%2Fapi-test-kit/lists"}