Skip to content

Add tests#240

Open
schneems wants to merge 6 commits intomainfrom
schneems/add-tests
Open

Add tests#240
schneems wants to merge 6 commits intomainfrom
schneems/add-tests

Conversation

@schneems
Copy link
Copy Markdown
Contributor

@schneems schneems commented Apr 25, 2026

The buildpack builds the project on Heroku CI already so we know it compiles. This adds tests to validate logic beyond making sure it compiles.

$ ./mvnw test
...
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0
[INFO] 
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.348 s
[INFO] Finished at: 2026-04-25T18:57:27-05:00
[INFO] ------------------------------------------------------------------------

Adds JUnit 5, Mockito, Spring Test, and MockMvc for writing
controller tests.
Tests use @WebMvcTest with a mocked DataSource to verify:
- GET / returns 200 and renders the index view
- GET /database returns records from a mocked connection
- GET /database returns 500 with error view on connection failure
Adds environments.test to app.json so Heroku CI provisions a
PostgreSQL database and runs mvn test automatically.
Spring Boot 4 moved @WebMvcTest to the spring-boot-webmvc-test
module. This dependency is required alongside spring-boot-starter-test.
- Use org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest
  (new package in Spring Boot 4)
- Remove status code assertion from error test since MockMvc view
  rendering resets the status set via HttpServletResponse.setStatus()
@heroku heroku Bot temporarily deployed to getting-star-schneems-a-ncxfds April 25, 2026 23:35 Inactive
In-dyno databases are ephemeral databases that run inside the test
dyno, providing faster startup than provisioning a real addon.
@heroku heroku Bot temporarily deployed to getting-star-schneems-a-ncxfds April 25, 2026 23:57 Inactive
@schneems schneems marked this pull request as ready for review April 25, 2026 23:57
@schneems schneems requested review from a team and Malax as code owners April 25, 2026 23:57
@edmorley edmorley removed the request for review from a team April 30, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant