{"id":18791893,"url":"https://github.com/saksmt/ktest","last_synced_at":"2025-04-13T14:30:46.519Z","repository":{"id":57742855,"uuid":"115024215","full_name":"saksmt/ktest","owner":"saksmt","description":"kTest - integration/acceptance/system/whatever test oriented modular test framework in Kotlin","archived":false,"fork":false,"pushed_at":"2019-01-31T10:33:01.000Z","size":373,"stargazers_count":12,"open_issues_count":17,"forks_count":2,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2024-01-27T16:20:20.808Z","etag":null,"topics":["acceptance-testing","integration-testing","kotlin","system-testing","test","test-automation","test-framework","testing","testing-framework","tests"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/saksmt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-12-21T16:12:18.000Z","updated_at":"2024-01-27T16:20:20.809Z","dependencies_parsed_at":"2022-09-11T07:01:38.354Z","dependency_job_id":null,"html_url":"https://github.com/saksmt/ktest","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Fktest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Fktest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Fktest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/saksmt%2Fktest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/saksmt","download_url":"https://codeload.github.com/saksmt/ktest/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223588983,"owners_count":17169900,"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":["acceptance-testing","integration-testing","kotlin","system-testing","test","test-automation","test-framework","testing","testing-framework","tests"],"created_at":"2024-11-07T21:17:27.601Z","updated_at":"2024-11-07T21:17:28.279Z","avatar_url":"https://github.com/saksmt.png","language":"Kotlin","readme":"# kTest\n\n[![CircleCI](https://img.shields.io/circleci/project/github/saksmt/ktest.svg?style=flat-square)](https://circleci.com/gh/saksmt/ktest) ![Maven metadata URI](https://img.shields.io/maven-metadata/v/http/oss.sonatype.org/content/repositories/releases/run/smt/ktest/ktest-api/maven-metadata.xml.svg?style=flat-square)\n\nkTest is integration / acceptance / system / any other non-unit test oriented modular test framework in Kotlin.\nInspired by [kotlintest](https://github.com/kotlintest/kotlintest), [specs2](https://github.com/etorreborre/specs2) and martians. \n\n## Usage\n\n### [Styling your test](doc/core/api.md)\n\n[//]: # (no_check)\n```kotlin\nobject MyTestSpecification : BehaviorSpec({\n    given(\"some service\") {\n        `when`(\"executing it's API\") {\n            then(\"it should work correctly\") {\n                // test body...\n            }\n        }\n    }\n})\n```\n\n### [Performing simple HTTP](doc/integration/rest-assured/rest.md)\n\n[//]: # (no_check)\n```kotlin\nfun makeMyHttp(): List\u003cAccount\u003e {\n    return rest[\"my-backend\"] {\n        using(url) {\n            agreements / param(\"id\") / accounts \n        } execute {\n            GET(pathParam(123), header(\"Accept\", \"application/json\"))\n        }\n    }\n}\n```\n\n### [Working with JSON](doc/integration/jackson.md)\n\n[//]: # (no_check)\n```kotlin\nfun loadAccounts(resourcePath: String) =\n    resourcePath.loadAsJson { list(map\u003cString, Any\u003e()) }.also {\n        println(it.dump()) // pretty-printing pseudo-logging\n    }\n```\n\n### [Matching over JSON](doc/integration/json-matcher.md)\n\n[//]: # (no_check)\n```kotlin\nfun compareMyJsons(expected: JsonNode, actual: JsonNode) {\n    with(JsonNodeMatchers) {\n        assertThat(actual, isIdenticalTo(expected).bySubtree {\n            // comparing only meaningful nodes\n            \"accounts[*]\" {\n                + \"id\"\n                + \"accountNumber\"\n                \n                \"owner\" {\n                    + \"id\"\n                    + \"name\"\n                }\n            }\n        })\n    }\n}\n```\n\n### [Searching over JSON](doc/integration/jsonpath.md)\n\n*Powered by [JSONPath](https://github.com/json-path/JsonPath)*\n\n[//]: # (no_check)\n```kotlin\nfun allIdsNearAccountNumbers(jp: DocumentContext) =\n    jp select \"id\" where {\n        \"accountNumber\".exists()\n    } castTo { list\u003cLong\u003e() }\n```\n\n### [Accessing database](doc/integration/spring-jdbc.md)\n\n[//]: # (no_check)\n```kotlin\nfun getAccounts(activeOn: Date) =\n    \"my-database\".db {\n        select\u003cAccount\u003e(\"\"\"\n           | SELECT * FROM accounts \n           | WHERE \n           |   close_date is NULL \n           |   OR close_date \u003c :activeOn\n        \"\"\".trimMargin()) {\n            parameter(\"activeOn\", activeOn)\n        }.asList()\n    }\n```\n\n### [REST specification](doc/integration/rest-assured/rest-test.md)\n\n[//]: # (no_check)\n```kotlin\nobject MyTest : SimpleSpec({\n    suite(\"my service suite\") {\n        restTest(name = { \"${it.method} accounts\" }) {\n            url { agreements / accounts }\n        \n            GET(queryParam(\"name\", \"%\"))\n            POST(body(\"name\", \"%\")) { it / search }\n            \n            expect { response: DocumentContext -\u003e\n                // do some check\n            }\n        }\n    }\n})\n```\n\n### [Configuring reporting engine](doc/integration/allure.md)\n\n*Reporting powered by excellent [Allure](http://allure.qatools.ru)*\n\n[//]: # (no_check)\n```kotlin\nobject MyTest : AllureSpec({\n    feature(\"some feature\", metaInfo = {\n        blocker()\n    }) {\n        story(\"true story\", metaInfo = {\n            issue(\"PROJ-111\")\n        }) {\n            case(\"my case\", metaInfo = {\n                description(\"my description\")\n            }) {\n                // test body...\n            }\n        }\n    }\n})\n```\n\n### Putting it all together\n\n[//]: # (no_check)\n```kotlin\nobject AccountByCustomerRestApiSpec : AllureSpec({\n    beforeAll {\n        rest[\"backend\"] {\n            using(url) {\n                `internal` / caches\n            } execute {\n                DELETE(queryParam(\"force\", \"true\"))\n            }\n        }\n    }\n\n    epic(\"Search\") {\n        feature(\"Account by customer search\") {\n            story(\"Single criteria search\") {\n                val testTable = table(\n                    header(\"criteriaName\", \"criteriaValue\", \"expectedJsonName\"),\n                    row(\"billing\", \"\u003e100\", \"richAccounts.json\"),\n                    row(\"region\", \"Central\", \"centralRegionAccounts.json\"),\n                    row(\"validTill\", \"\u003e${LocalDate.now().format(DateTimeFormatter.ISO_DATE)}\", \"activeAccounts.json\")\n                )\n                // should be generated right before test\n                val myGeneratedCustomer: Customer = testData[\"customer.json\"]\n                \n                forAll(testTable) { criteriaName, criteriaValue, expectedJsonName -\u003e\n                    val criteria = mapOf\u003cString, String\u003e(\n                        criteriaName, criteriaValue\n                    )\n                    \n                    restTest(name = { \"Search account by \\\"$criteriaName\\\": ${it.method}\" }, metaData = {\n                        category\u003cComplex\u003e()\n                        flaky()\n                    }) {\n                        url { customers / param(\"customerId\") / accounts }\n                        \n                        GET(queryParams(criteria), pathParam(\"customerId\", myGeneratedCustomer.id))\n                        POST(body(criteria), pathParam(\"customerId\", myGeneratedCustomer.id))\n                        \n                        expect { response: DocumentContext -\u003e\n                            with(DocumentContextMatchers) {\n                                assertThat(response, matches(expectedJsonName.loadAsJsonPath()).afterRemovalOfSubtree {\n                                    \"account[].metaData\" {\n                                        + \"date\"\n                                        + \"IP\"\n                                    }\n                                })\n                            }\n                        }\n                    }\n                }\n            }\n        }\n    }\n})\n```\n\nFor more see [docs](doc/README.md) and [samples](sample)\n\n## Download\n\nYou can use [dependency management](doc/pom.md)\n\n### Gradle\n\n```groovy\ncompile 'run.smt.ktest:ktest-api'\ncompile 'run.smt.ktest:ktest-config'\ncompile 'run.smt.ktest:ktest-util'\ncompile 'run.smt.ktest:ktest-runner-junit4'\ncompile 'run.smt.ktest:ktest-allure'\ncompile 'run.smt.ktest:ktest-jackson'\ncompile 'run.smt.ktest:ktest-json-matchers'\ncompile 'run.smt.ktest:ktest-jsonpath'\ncompile 'run.smt.ktest:ktest-db'\ncompile 'run.smt.ktest:ktest-rest'\ncompile 'run.smt.ktest:ktest-resttest'\n```\n\n### Maven\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-api\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-config\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-util\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-runner-junit4\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-allure\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-jackson\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-json-matchers\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-jsonpath\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-db\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-rest\u003c/artifactId\u003e\n\u003c/dependency\u003e\n\n\u003cdependency\u003e\n    \u003cgroupId\u003erun.smt.ktest\u003c/groupId\u003e\n    \u003cartifactId\u003ektest-resttest\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\n## License\n\nAll source code is licensed under [MIT license](LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaksmt%2Fktest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsaksmt%2Fktest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsaksmt%2Fktest/lists"}