I’m, writing an integration test, annotated with @SpringBootTest. Suppose I create some product using pure SQL from my test, call calculation service that do some calculations based on it, and it calls another service to save those calculation results in different tables. What I need is to rollback all the changes made after test is finished. I read different questions,
Tag: integration-testing
How do I load environment variables to load application context before integration test runs
I’m working on multi-module maven project using Spring Boot 2.4.0. I have written integration tests for a module. The test class looks similar to this. @RunWith(SpringRunner.class) @SpringBootTest(…
Best practice for Unit Testing class which is mostly responsible to call methods of dependencies, but contains logic as well
Let’s assume I have StartCommandHandler which has responsibility to create some file with required files. But for doing this I have to give him a set of sub-responsibilities, like: Checks whether …
Unit Test or Integration Test in Spring Boot
I looked various tutorial online related to testing in Spring Boot and got confused by the way the tests were referred. Some articles refer to controller tests that use @WebMvcTest annotation as …
Why component scanning does not work for Spring Boot unit tests?
The service class FooServiceImpl is annotated with @Service aka @Component which makes it eligible for autowiring. Why this class is not being picked up and autowired during unit tests? The test failed to load application context, Full stack trace If test class is annotated with @SpringBootTest then it creates whole application context including database connection and a lot of unrelated
Embedded MongoDB when running integration tests
My question is a variation of this one. Since my Java Web-app project requires a lot of read filters/queries and interfaces with tools like GridFS, I’m struggling to think of a sensible way to employ MongoDB in the way the above solution suggests. Therefore, I’m considering running an embedded instance of MongoDB alongside my integration tests. I’d like it to