question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide module-scoped equivalents to @WebMvcTest and @DataJpaTest

See original GitHub issue

With @WebMvcTest and @DataJpaTest we can easily create an ApplicationContext for the web- or data layer of our Spring Boot Application.

It would be nice to have equivalents to these annotations that only include the web- or data layer of our module under test into the ApplicationContext.

Same goes for the other annotations like @WebfluxTest, @JdbcTest and so on (see https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-testing.html).

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:25

github_iconTop GitHub Comments

2reactions
odrotbohmcommented, Aug 15, 2018

Looks like @sbrannen was kind enough to add support for an escape hatch by adding an explicit annotation on the test class in Spring Framework 5.1.

Would you mind giving this another look on 5.1, @thombergs?

0reactions
tilm4nncommented, May 18, 2022

I just realized that the test works when I specify all three together

@ModuleTest
@SpringBootTest
@AutoConfigureMockMvc

But what does this mean for the bootsrapping? Does it initialize the whole application or only the current module?

Read more comments on GitHub >

github_iconTop Results From Across the Web

SpringBootTest Vs @WebMvcTest & @DataJpaTest &service ...
I have a SpringBoot MVC application, and I want to cover it with tests. I have the controller, service and repository layers. What...
Read more >
Testing MVC Web Controllers with Spring Boot and ...
An in-depth look at the responsibilities of a Spring Boot web controller and how to cover those responsibilities with meaningful tests.
Read more >
40. Testing - Spring
Spring Boot provides a number of utilities and annotations to help when testing your application. Test support is provided by two modules; spring-boot-test ......
Read more >
Difference between @WebMvcTest and @DataJpaTest in ...
The @DataJpaTest annotation in Spring Boot is used to test the persistence layer components that autoconfigure in-memory embedded databases and look for @Entity ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found