Skip to main content

All Questions

Tagged with
0 votes
1 answer
34 views

JUnit run End-to-End Test with multiple Services

I am trying to run End-to-End tests with JUnit and RestTemplates. I have a Spring / Maven Multi Module Project in the following structure: parent |-- service-1 |-- service-2 |-- service-3 |-- ...
FWidder's user avatar
  • 43
0 votes
0 answers
168 views

IllegalState Failed to load ApplicationContext in GitHub Actions pipeline

I am getting IllegalState Failed to load ApplicationContext for for [WebMergedContextConfiguration@74764622 testClass = errors when GitHub runs my pipeline. However the tests pass when I am running ...
sergiu's user avatar
  • 3
0 votes
1 answer
44 views

How to test @Valid with JUnit5, @SpringBootTest?

This is my Controller class. import jakarta.validation.Valid; import jakarta.validation.constraints.NotNull; import org.springframework.http.ResponseEntity; import org.springframework.web.bind....
이성호's user avatar
0 votes
1 answer
51 views

GraphQLTestTemplate returning "Body is empty with status 401" for SpringBoot and GraphQL integration testing

I have been working on integration testing using SpringBoot + GraphQL following this tutorial: https://www.youtube.com/watch?v=bdfEjn6xZx0 which I found pretty straightforward. However, when I execute ...
Marcelo Tataje's user avatar
2 votes
0 answers
125 views

Configure JUnit to run on 5 threads, each using a different datasource

TL;DR How to configure my JUnit test suite to run on 5 threads, each using a different datasource? I'm trying to speed up my SpringBoot/JUnit 5 integration tests, which currently take over 40 minutes. ...
Bruno Carneiro's user avatar
0 votes
0 answers
43 views

The application.properties values are not read in java tests

I have the following service, where I use the properties of my application.properties file: @Service public class TesoSunSystemsServiceImpl implements TesoSunSystemsService { @Value(&...
BRUNO's user avatar
  • 23
1 vote
2 answers
122 views

How to enable DEBUG level for unit tests in Springboot 3.1.10?

I need to enable debug mode globally, so output from the application classes is logged in both application and unit tests. I enabled DEBUG mode in src\main\resources\application.properties and it ...
tim bits's user avatar
0 votes
1 answer
70 views

Failed to load ApplicationContext for my JUnit test

I followed an article about JUnit testing wrote a JUnit test for my User model: import dev.cv.taskmasterserver.entity.User; import dev.cv.taskmasterserver.repository.UserRepository; import org.junit....
cube's user avatar
  • 1
0 votes
0 answers
34 views

Log JUnit ClassOrderer Random Seed with Spring Boot and Logback

I am trying to log the JUnit ClassOrderer random seed using Logback, Spring Boot and Gradle. I found How can I make my JUnit tests run in random order? as related to my problem, but it uses the JUL ...
user2715478's user avatar
  • 1,273
0 votes
2 answers
40 views

Mockito service dependency null pointer exception

So, let me show my problem. I have Service class: @Service @Transactional public class UserServiceImpl implements UserService { private final UserRepository userRepository; private final ...
IvanDx's user avatar
  • 17
-3 votes
1 answer
83 views

Mockito Junit test case for while loop with break statement [duplicate]

I am writing Junit test case(Junit 5 with jupitar) for existing code that has while loop with break statement. public int deleteRecords(int batchsize) { //some code here int totalDeletedRecords ...
Anil Nivargi's user avatar
  • 1,655
0 votes
2 answers
136 views

How to mock HashMap in JUnit test in Spring Boot (Throws nullpointerexception)

I have a problem to write JUnit test for the method in my Spring Boot example shown below. I cannot handle with the mock implementation in HashMap in JUnit test as it throws null pointer execption in ...
jacksondel's user avatar
0 votes
0 answers
94 views

Embedded Kafka Failed to Start After Spring Starter Parent Version 3.1.10

I'm trying to run some integration tests for Kafka consumer with, org.springframework.kafka.test.context.EmbeddedKafka Currently letting spring-boot-starter-parent to do the dependency version ...
Saddeep Mihiranga's user avatar
-1 votes
1 answer
34 views

How to mock dependency in service class from Junit

I am trying to write the test cases of one of my service method. I am packing error like cannot invoke Cannot invoke "com.company.app.models.Product.getId()" because "product" is ...
David's user avatar
  • 4,142
0 votes
1 answer
47 views

Autowire class's dependencies in jUnit without manual construction

My Service class has several autowired objects (Stored Procedures, SPs). Rather than a MockBean when/then, one test actually requires me to autowire the SP dependency objects in full, to see which ...
gene b.'s user avatar
  • 11.5k

15 30 50 per page