Skip to content
Advertisement

Tag: integration-testing

How to make an integration test with one transaction for all database calls and rollback it afterwards?

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,

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. To run the SpringApplicationClassWithMainMethod.class i.e., in order to load the Application context I need few environment variables that I set in eclipse. So, in order to run the above integration test while loading the SpringApplicationClassWithMainMethod.class

Micronaut test in docker overriding the MICRONAUT_ENVIRONMENTS

We run our micronaut integration tests in the cloud in a docker container We’re setting the MICRONAUT_ENVIRONMENTS=staging in the docker environment variables, to force our application to read the config values from application-staging.yaml. However, micronaut is automatically adding “test” as an environment, and then read the config values from application-test.yaml. From the docs (https://docs.micronaut.io/2.2.1/guide/index.html#propertySource), environment variables should have priority compared

Integration test fails when upgrading failsafe but passes within intellij

I have a multi maven module project. The project runs fine and everything passes, but if I upgrade failsafe plugin from 2.22.2 to the latest version 3.0.0-M5 the integration test within two of the maven modules(client and server-with-jersey) fails. I have tried different configuration, but I am not quite sure what to do anymore… So I am hoping that the

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 file exists in the FTP If Not downloads files from multiple sources to the temp folder Then executes some script in the folder Then read generated file after script

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

How to run integration test of a spring-boot based application through maven-failsafe-plugin?

I have a spring-boot based application, and the pom.xml file is configured as below. The main method located in class DemoApplication as below And my integration test class called DemoIT as following. Now here is my question, when I issue mvn clean verify command, the integration class DemoIT is supposed to be executed, and it does. However, my DemoApplication isn’t

Advertisement