Skip to main content
The 2024 Developer Survey results are live! See the results

All Questions

Tagged with
1 vote
0 answers
42 views

SpringBootTest with Togglz

I just recently added togglz to the spring-boot 3.1.9 application, which contains also much stuff like spring-security, spring-data, etc. Maven dependency: <dependency> <groupId>org....
Georgii Lvov's user avatar
  • 2,474
1 vote
1 answer
36 views

I cant init my webclient in a test with mockito

I'm working on a project with java spring boot 2.x and java 1.8. In my pom i got the dependencies of junit 4.13.2 and mockito 3.12.4. When i try to run my test i got the problem that my setup function ...
Juan Federico Di Leo's user avatar
0 votes
0 answers
44 views

How to mock Files API from java.nio.file.*

I am using Java nio API and have a below code, but unable to perform mocking on the below code. Path path = Paths.get(filePath); long sizeInBytes = Files.size(path); long recordCount = 0; try (Stream&...
PAA's user avatar
  • 11.5k
1 vote
2 answers
43 views

Is it advisable to repeat an integration test that is used in more than one method?

I'm developing a project. This project has a repository (UserRepository) which is referenced by other parts of the project, I want to know if I have to test the repository method each time it is ...
Mateus Fonseca's user avatar
0 votes
0 answers
26 views

mockito, mock new file or mock file.exists() [duplicate]

Prerequisite: Powermockito cannot be used and the original code cannot be changed. how to let File file = new File("xxxx"); file.exists() returns true. public void testFile(String path) { ...
user25724873's user avatar
0 votes
0 answers
46 views

When I perform spring-boot unit testing, the spring datasource is repeatedly initialized

I'm using Groovy + Spock to perform unit testing for a Spring-boot project. I have two test classes, Test Class A and Test Class B. These two test classes are independent and have no dependency ...
Mike Wu's user avatar
-1 votes
1 answer
43 views

How to unit test Mapper provided by MapStruct?

I want to unit test my MapStruct mappers, if that is a thing, should I use Mockito, or can I just call mapper = new UserMapperImpl();. UserMapperTest.java class UserMapperTest { private ...
Davido's user avatar
  • 95
1 vote
1 answer
56 views

Testing Routes with Spring Boot und JUnit

Hello I really need help testing my routes (if that is even a good practice). Setup: Spring Boot JUnit Vaadin I want to test my protected routes, which only admins should be able to get access to. ...
chris's user avatar
  • 11
1 vote
1 answer
38 views

Sprinboot api application performance test

I want to test the performance of my backend REST API application written with Spring Boot under high requests. How can I perform this process? Which tools should I use and what should I do step by ...
scofield1's user avatar
0 votes
2 answers
56 views

Junit local object mock with arguments

I want to use mockito for mocking the constructor call when a specific argument is passed. Lets say this is my class - public class MyTestClass { private final String argument; public ...
Arjun's user avatar
  • 13
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 ...
Syed Ali's user avatar
-1 votes
3 answers
83 views

doNothing when on abstract class method but should work when called from concreate class instance

I have following structure: class Sample { private Map<String A> serviceMap; @Autowired private List<A> services; @PostConstruct public void init() { this.serviceMap = this....
Rohit Raj's user avatar
0 votes
0 answers
32 views

Spring Boot using a bean from a config class that is not specified in the @Import annotation

I am trying to implement two tests for a Spring Batch Job, each test needing one bean in particular to have different properties when the Spring Context loads it in. One test class is the following: @...
lotario's user avatar
0 votes
2 answers
94 views

java.lang.IllegalArgumentException: From address must not be null

I have a project with Java 17 and Spring 3. In my pom.xml the Test extensions are the following: junit-jupiter: version 5.10.1. mockito-core: version 5.8.0. mockito-junit-jupiter: version 5.8.0 I ...
diego evangeliste's user avatar
-1 votes
2 answers
74 views

In unit tests, how to mock values in test classes before the constructor of injected service class works

I am writing unit tests for a service class, let's call it MyService, which is in the following format: public class MyService { private final HttpHeaders headers = new HttpHeaders(); public ...
Laziz's user avatar
  • 11

15 30 50 per page
1
2 3 4 5
229