CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/springboot-testing

Spring Boot testing — @WebMvcTest for controllers, @DataJpaTest for repositories, @SpringBootTest only for integration, MockMvc, @MockBean vs @Mock, AssertJ, @Transactional rollback, @ActiveProfiles, TestContainers

93

1.09x
Quality

89%

Does it follow best practices?

Impact

100%

1.09x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-1/

Bookstore Test Infrastructure

Add test infrastructure to an existing Spring Boot bookstore application. The app uses PostgreSQL in production and has:

  • BookController with GET /api/books and POST /api/books
  • BookService for business logic
  • BookRepository extends JpaRepository<Book, Long>
  • Book entity with fields: id, title, author, isbn, price

The project currently has no tests. Set up the test infrastructure and write sample tests for each layer.

Output

Produce:

  1. src/test/resources/application-test.yml -- test database configuration
  2. src/test/java/com/example/bookstore/controller/BookControllerTest.java -- controller slice test
  3. src/test/java/com/example/bookstore/repository/BookRepositoryTest.java -- repository slice test
  4. src/test/java/com/example/bookstore/BookstoreIntegrationTest.java -- integration test

Each test file should contain at least 2 test methods. Do not produce the application source code.

evals

scenario-1

criteria.json

task.md

tile.json