{"id":26781824,"url":"https://github.com/wiiitek/its","last_synced_at":"2026-04-05T23:35:25.696Z","repository":{"id":38195584,"uuid":"370180378","full_name":"wiiitek/its","owner":"wiiitek","description":null,"archived":false,"fork":false,"pushed_at":"2026-03-01T18:54:24.000Z","size":866,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-03-01T20:54:18.866Z","etag":null,"topics":["integration-testing","kotlin","postgresql","spock","spring","springboot"],"latest_commit_sha":null,"homepage":"","language":"Groovy","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/wiiitek.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-05-23T23:49:28.000Z","updated_at":"2026-03-01T18:54:27.000Z","dependencies_parsed_at":"2023-10-23T20:31:35.540Z","dependency_job_id":"c6fe154c-a4d6-4bff-a9bd-df8a2cfa2038","html_url":"https://github.com/wiiitek/its","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wiiitek/its","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiiitek%2Fits","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiiitek%2Fits/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiiitek%2Fits/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiiitek%2Fits/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wiiitek","download_url":"https://codeload.github.com/wiiitek/its/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wiiitek%2Fits/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31454199,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["integration-testing","kotlin","postgresql","spock","spring","springboot"],"created_at":"2025-03-29T08:18:14.956Z","updated_at":"2026-04-05T23:35:25.676Z","avatar_url":"https://github.com/wiiitek.png","language":"Groovy","readme":"# its\n\n[![CI](https://github.com/wiiitek/its/actions/workflows/main.yml/badge.svg)](https://github.com/wiiitek/its/actions/workflows/main.yml)\n[![sonarcloud.io](https://sonarcloud.io/api/project_badges/measure?project=wiiitek_its\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=wiiitek_its)\n\nIntegration Testing examples for [Spring Test Slices].\n\nSome links about Test Slices:\n\n- [Spring Test Slices at sudoinit5.com]\n- [Integration Testing With @DataJpaTest at baeldung.com]\n\n## @DataJdbcTest\n\n[@DataJdbcTest] applies only the Spring configuration relevant to Data JDBC tests.\n\nTests run with no DB connection by default:\n\n- [`TestEmployeeRepositoryJdbcSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/jdbc/TestEmployeeRepositoryJdbcSpec.groovy)\n- [`EmployeeExposedRepositoryDataSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/exposed/EmployeeExposedRepositoryDataSpec.groovy)\n\nIt can also be configured to use [embedded database] (H2, DERBY, HSQLDB).\nWith some effort it is also a possible to use [embedded PostgreSQL]:\n\n- [`EmployeeJdbcRepositoryEmbeddedSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/jdbc/EmployeeJdbcRepositoryEmbeddedSpec.groovy)\n- [`EmployeeExposedRepositoryEmbeddedSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/exposed/EmployeeExposedRepositoryEmbeddedSpec.groovy)\n\n\u003e By default, tests annotated with @DataJdbcTest are transactional and roll back at the end of each test.\n\n## @DataJpaTest\n\n[@DataJpaTest] provides Spring configuration to support JPA repositories and Entities:\n\n- [`EmployeeJpaRepositoryDataSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/jpa/EmployeeJpaRepositoryDataSpec.groovy)\n- [`EmployeeJpaRepositoryEmbeddedSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/jpa/EmployeeJpaRepositoryEmbeddedSpec.groovy)\n\nthey can also inject [TestEntityManager] to help testing repositories while using [first-level cache].\n\nAdditional info for using Kotlin with Spring JPA:\n\n- [Hibernate with Kotlin - powered by Spring Boot at kotlinexpertise.com]\n\n`kotlin(\"plugin.jpa\")` provides no-args constructor for our entities (https://stackoverflow.com/a/41365380).\n\n\u003e By default, tests annotated with @DataJpaTest are transactional and roll back at the end of each test.\n\n## @Testcontainers\n\nWe can use testcontainers to create all of our application beans for integration tests.\n\n1. Slowest, but use *real* database.\n2. Requires some setup and config values for DB connection:\n   - [`TestcontainersSpringBaseTest`](https://github.com/wiiitek/its/blob/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/TestcontainersSpringBaseTest.groovy)\n3. Database changes made by tests are **not** rolled back at the end.\n\nExamples:\n\n- [`EmployeeJdbcRepositoryTestcontainersSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/jdbc/EmployeeJdbcRepositoryTestcontainersSpec.groovy)\n- [`EmployeeExposedRepositoryTestcontainersSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/exposed/EmployeeExposedRepositoryTestcontainersSpec.groovy)\n- [`EmployeeJpaRepositoryTestcontainersSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/jpa/EmployeeJpaRepositoryTestcontainersSpec.groovy)\n\n## @WebMvcTest\n\n[@WebMvcTest] annotation can be used to test controllers separately:\n\n1. With `MockMvc` - compare also [Guide to Testing Spring Boot Applications With MockMvc]\n2. With `WebTestClient` - see [Spring framework docs for WebTestClient]\n\nUsually we use it with `@MockBean` for services used by the tested controller.\n\nExamples are provided in:\n\n- [`EmployeesControllerMockMvcSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/EmployeesControllerMockMvcSpec.groovy)\n- [`EmployeesControllerWebTestClientSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/EmployeesControllerWebTestClientSpec.groovy)\n- [`CatsControllerMockMvcSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/cats/CatsControllerMockMvcSpec.groovy)\n\nWe can use `MockMvc` without `@WebMvcTest` annotation\n(compare with [Setup Choices](https://docs.spring.io/spring-framework/reference/testing/spring-mvc-test-framework/server-setup-options.html) documentation page).\nHowever, even in standalone mode the servlet context still needs to be created.\n\n- [`EmployeesControllerMockMvcUnitSpec`](https://github.com/wiiitek/its/tree/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/employees/EmployeesControllerMockMvcUnitSpec.groovy)\n\n## WireMock\n\nThis project uses [WireMock](https://wiremock.org/docs/overview/) to record expected answers from 3rd party service.\nIn\n[CatFactClientSpec](https://github.com/wiiitek/its/blob/main/server/src/test/groovy/pl/kubiczak/test/spring/integration/demo/server/cats/CatFactClientSpec.groovy)\nwe:\n\n1. specify how WireMock server should respond\n2. verify that our code can correctly interact with specified response\n\n## Spring Cloud Contract\n\n[Spring Cloud Contract] describes behaviour of our API with [Contract DSL].\n\n1. On the producer side:\n    * Verifies if the server behaves as described in contract\n2. On the consumer side:\n    * Creates WireMock stub server to test client code\n\nWe can write the contract first, and then implement server and client independently.\nSee also:\n\n* [Spring Cloud Contract Reference Documentation]\n* [Spring Cloud Contract samples]\n\n## Springfox\n\nSwagger UI is available at http://localhost:8080/swagger-ui/index.html.\n\n## Gradle upgrade\n\n```bash\n./gradlew wrapper --gradle-version latest\n```\n\n[Spring Test Slices]: https://www.baeldung.com/spring-tests#5-using-test-slices\n[Spring Test Slices at sudoinit5.com]: https://www.sudoinit5.com/post/spring-test-slices/#testing-just-jpa\n[Integration Testing With @DataJpaTest at baeldung.com]: https://www.baeldung.com/spring-boot-testing#integration-testing-with-datajpatest\n\n[@DataJdbcTest]: https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing.spring-boot-applications.autoconfigured-spring-data-jdbc\n[@DataJpaTest]: https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing.spring-boot-applications.autoconfigured-spring-data-jpa\n[@WebMvcTest]: https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing.spring-boot-applications.spring-mvc-tests\n\n[embedded database]: https://github.com/spring-projects/spring-boot/blob/main/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java\n[embedded PostgreSQL]: https://stackoverflow.com/a/49011982\n\n[Hibernate with Kotlin - powered by Spring Boot at kotlinexpertise.com]: https://kotlinexpertise.com/hibernate-with-kotlin-spring-boot/\n\n[TestEntityManager]: https://zetcode.com/springboot/testentitymanager/\n[first-level cache]: https://howtodoinjava.com/hibernate/understanding-hibernate-first-level-cache-with-example/\n\n[Guide to Testing Spring Boot Applications With MockMvc]: https://rieckpil.de/guide-to-testing-spring-boot-applications-with-mockmvc/\n[Spring framework docs for WebTestClient]: https://spring.getdocs.org/en-US/spring-framework-docs/docs/testing/integration-testing/webtestclient.html\n\n[Spring Cloud Contract]: https://spring.io/projects/spring-cloud-contract\n[Contract DSL]: https://cloud.spring.io/spring-cloud-contract/reference/html/project-features.html#contract-dsl\n[Spring Cloud Contract Reference Documentation]: https://cloud.spring.io/spring-cloud-contract/reference/html/index.html\n[Spring Cloud Contract samples]: https://github.com/spring-cloud-samples/spring-cloud-contract-samples\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiiitek%2Fits","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwiiitek%2Fits","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwiiitek%2Fits/lists"}