{"id":18048051,"url":"https://github.com/ivangfr/springboot-testing-mysql","last_synced_at":"2025-04-10T09:48:29.209Z","repository":{"id":111328748,"uuid":"128530193","full_name":"ivangfr/springboot-testing-mysql","owner":"ivangfr","description":"Goals: 1) Create a simple Spring Boot application to manage users; 2) Explore the utilities and annotations that Spring Boot provides for testing; 3) Test using Testcontainers.","archived":false,"fork":false,"pushed_at":"2025-03-07T11:34:56.000Z","size":1076,"stargazers_count":3,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T08:42:33.756Z","etag":null,"topics":["integration-testing","java","mysql","spring-boot","spring-data-jpa","spring-web-mvc","springdoc-openapi","testcontainers","unit-testing"],"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/ivangfr.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"ivangfr"}},"created_at":"2018-04-07T13:20:13.000Z","updated_at":"2025-03-07T11:35:00.000Z","dependencies_parsed_at":"2023-10-16T23:59:26.365Z","dependency_job_id":"96314011-1eca-4c0a-9d71-4bf23af8ae32","html_url":"https://github.com/ivangfr/springboot-testing-mysql","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspringboot-testing-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspringboot-testing-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspringboot-testing-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ivangfr%2Fspringboot-testing-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ivangfr","download_url":"https://codeload.github.com/ivangfr/springboot-testing-mysql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248197321,"owners_count":21063619,"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":["integration-testing","java","mysql","spring-boot","spring-data-jpa","spring-web-mvc","springdoc-openapi","testcontainers","unit-testing"],"created_at":"2024-10-30T20:11:05.731Z","updated_at":"2025-04-10T09:48:29.165Z","avatar_url":"https://github.com/ivangfr.png","language":"Java","funding_links":["https://github.com/sponsors/ivangfr"],"categories":[],"sub_categories":[],"readme":"# springboot-testing-mysql\n\nThe goals of this project are to:\n- Create a simple [`Spring Boot`](https://docs.spring.io/spring-boot/index.html) application to manage users called `user-service`. The database used is [`MySQL`](https://www.mysql.com);\n- Explore the utilities and annotations that `Spring Boot` provides for testing applications;\n- Test using [`Testcontainers`](https://testcontainers.com).\n\n## Proof-of-Concepts \u0026 Articles\n\nOn [ivangfr.github.io](https://ivangfr.github.io), I have compiled my Proof-of-Concepts (PoCs) and articles. You can easily search for the technology you are interested in by using the filter. Who knows, perhaps I have already implemented a PoC or written an article about what you are looking for.\n\n## Project Diagram\n\n![project-diagram](documentation/project-diagram.jpeg)\n\n## Application\n\n- ### user-service\n\n  `Spring Boot` Web Java application to manage users. The data is stored in `MySQL`.\n  \n  ![user-service-swagger](documentation/user-service-swagger.jpeg)\n\n## Prerequisites\n\n- [`Java 21`](https://www.oracle.com/java/technologies/downloads/#java21) or higher;\n- A containerization tool (e.g., [`Docker`](https://www.docker.com), [`Podman`](https://podman.io), etc.)\n\n## Start Environment\n\n- Open a terminal and inside the `springboot-testing-mysql` root folder run:\n  ```\n  docker compose up -d\n  ```\n\n- Wait for the `MySQL` Docker container to be up and running. To check it, run:\n  ```\n  docker ps -a\n  ```\n\n## Start Application\n\n- In a terminal, make sure you are in the `springboot-testing-mysql` root folder;\n\n- Run application:\n  ```\n  ./gradlew user-service:clean user-service:bootRun\n  ```\n\n- The Swagger website can be accessed at http://localhost:8080/swagger-ui.html\n\n## Shutdown\n\n- Go to the terminal where `user-service` is running and press `Ctrl+C`;\n\n- In a terminal, inside the `springboot-testing-mysql` root folder, run the command below to stop and remove the Docker Compose `mysql` container and network:\n  ```\n  docker compose down -v\n  ```\n\n## Running Unit and Integration Tests\n\n- In a terminal, navigate to the `springboot-testing-mysql` root folder;\n\n- Running Tests\n\n  - Unit Tests only:\n    ```\n    ./gradlew user-service:clean user-service:cleanTest user-service:test\n    ```\n\n  - Unit and Integration Tests:\n    ```\n    ./gradlew user-service:clean user-service:cleanTest user-service:check user-service:integrationTest\n    ```\n    \u003e **Note**: During the tests, `Testcontainers` automatically starts the `MySQL` Docker container before the tests begin and shuts it down when the tests finish.\n\n- **Unit Test Report** can be found at:\n  ```\n  user-service/build/reports/tests/test/index.html\n  ```\n\n- **Integration Test Report** can be found at:\n  ```\n  user-service/build/reports/tests/integrationTest/index.html\n  ```\n\n## Useful Commands\n\n- **MySQL**\n  ```\n  docker exec -it -e MYSQL_PWD=secret mysql mysql -uroot --database userdb\n  SELECT * FROM users;\n  ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangfr%2Fspringboot-testing-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fivangfr%2Fspringboot-testing-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fivangfr%2Fspringboot-testing-mysql/lists"}