BookLore icon indicating copy to clipboard operation
BookLore copied to clipboard

Bootstrap automated testing: add first SmokeTest, H2 “test” profile, and coverage pipeline

Open afairgiant opened this issue 7 months ago • 1 comments

Until now BookLore‑API had zero automated tests. This PR lays the foundation for a proper testing culture by introducing:

A minimal yet powerful test tool‑chain (JUnit 5 + Mockito 5 + AssertJ).

An in‑memory H2 datasource for isolated unit tests.

A fast SmokeTest that confirms the Spring context can start on every commit.

JaCoCo coverage reporting with an enforceable threshold.

How to use:

./gradlew clean test            # should show BUILD SUCCESSFUL
./gradlew jacocoTestReport      # coverage HTML in build/reports/jacoco/test/html

Follow‑ups

Add service‑level tests for FileUploadService, BooksService, and processors now that the baseline test environment is stable.

Wire GitHub Actions workflow to run ./gradlew check and publish coverage artifacts.

afairgiant avatar May 22 '25 00:05 afairgiant

The maintainer was reluctant to switch to H2 altogether. I think it's better to just spin up y MariaDB instance via testcontainers instead of relying on H2's compatibility mode.

Edit: The other PR that does a simple context test already does this, you can take a look there. Imho your setup is overall better and more complete, but using H2 for integration tests is kind of outdated and you'll run into incompatibilities eventually because you're not really testing that everything works with the MySQL/MariaDB version of your choice, just that Hibernate generates the correct H2 syntax.

Schaka avatar May 27 '25 17:05 Schaka

Test suite initialized in: https://github.com/adityachandelgit/BookLore/pull/631

acx10 avatar Jun 30 '25 23:06 acx10