All Questions
Tagged with spring-boot junit
2,368
questions
0
votes
0
answers
38
views
How can I remove all running docker containers after all tests in a JUnit test suite have finished running?
I have a JUnit test suite that comprises of 3 smaller test suites. When these tests are run, 2 docker containers are spun up (an oracle slim db and an elasticsearch). I want to be able to remove these ...
0
votes
1
answer
49
views
How can I make a multiple level of mock object
Here is my example of object
@Service
public class UserSshKeyService {
private final RecordEventService eventService;
private final UserSshKeyRepository repository;
public ...
-1
votes
1
answer
164
views
How to mock a repository with Spring Data JPA + Specification
There is a basic CRUD API, and I want to test the UserServiseImpl.java class in its Service layer. In UserServiseImpl, entities are retrieved with
userRepository.findAll(query)
as shown below, and I ...
0
votes
1
answer
81
views
Mockito Test Fails with 'Wanted but not Invoked; Actually, there were zero interactions' Error
I'm facing issues with a unit test in a Spring Boot application where a specific repository method isn't being called as expected during the test of a service method. Despite setting up the test with ...
3
votes
1
answer
34
views
Test Coverage for DB call java code after couchbase 7.2 upgrade
We have recently upgraded Couchbase DB from 6.x to 7.2 . Which introduced collection and scope along with bucket. That means this
GetResult serviceInventoryJsonDocument = this.bucket....
1
vote
0
answers
89
views
How to mock constructors using mockito? [duplicate]
I am testing a method some class which has a new constructor call of BuildingBlockDbHandler.class. I was earlier using powermock to mock constructors like this way -
BuildingBlockDbHandler ...
0
votes
1
answer
48
views
How to write JUnit test for Gateway Application in Spring Boot Microservices
I have a problem to implement some JUnit test for Gateway Application in Spring Boot Microservices
Here is the Gateway Service Application shown below
@EnableDiscoveryClient
@SpringBootApplication
...
0
votes
0
answers
31
views
Testing method annotated with @Cacheable
I have to test a method thats annotated with @Cacheable like this im not,that skilled so this may be wrong.
@Trace
@Cacheable(value = "pp-search")
public Response search(final ...
2
votes
1
answer
73
views
Create uber file from Maven Surefire configuration
The current stack is Maven with modules per domain.
The main module imports the others.
And have a basic spring application on src and a testNG/cucumber/springboot runner on test.
I run that test ...
0
votes
2
answers
289
views
NoSuchMethodError: 'java.util.Set org.junit.platform.engine.TestDescriptor.getAncestors() when running Spock Spring Boot unit tests
Context
I have a unit test written using the Spock Testing framework to test my Spring Boot application.
I've declared the following test dependencies:
spock-spring: 2.3-groovy-4.0
spring-boot-...
0
votes
0
answers
52
views
SpringBoot configuration
I'm trying to run the following code using JUnit test (Run As -> JUnit Test).
I'm using Maven for dependency management, so I would have and understand that it's a configuration issue.
I've seen ...
0
votes
0
answers
51
views
Tests passing in IntelliJ, failing using mvn
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.junit.jupiter.MockitoExtension;
import static org.junit....
1
vote
0
answers
42
views
Inject JobLauncherTestUtils without using the @Autowired in unit test and spring batch
I'm new with Spring Batch and I'm trying to create an unit test for my job without using spring Boot and spring Batch annotations, only the mockito, however when i mock the JobLauncherTestUtils my ...
0
votes
1
answer
67
views
How can I delete all database entities after the tests are completed?
I was looking if there is a way with some kind of annotation rather than with code to clean the database after a test generated registries in it. I found about @Dirtiescontext but it doesn't seem to ...
0
votes
1
answer
39
views
Getting java.lang.NoClassDefFoundError Exception while using MockMvcBuilders.standaloneSetup() method in Junit 5
Below is my Test class that I have created for Controller class.
My Testclass is in package src/test/java and my java classes are in folder src/main/java.
public class MyControllerTest {
@...