Skip to main content

All Questions

0 votes
1 answer
48 views

How to use class member variables inside Junit-Mockito tests

class MyClass { MyErrorServiceList myErrorServiceList; // myErrorServiceList is initialized by some complex method calls public boolean processErrorServiceList() { if (...
Henry Passion's user avatar
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
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 ...
Japkutija's user avatar
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 ...
AG Garcia's user avatar
0 votes
1 answer
75 views

Null pointer Exception in spring boot testing

I have recently started to learn spring boot junit testing using mockito, but i get stuck very often. Here's my problem: I have created a simple addEmployeeTest, which results in null pointer ...
ross geller's user avatar
0 votes
0 answers
96 views

MockMvc get perform returns status 200 but without response body

I have an issue with REST Controller testing: @WebMvcTest(PersonController.class) public class Testing { @MockBean PersonService personService; @MockBean ...
David Masson's user avatar
0 votes
1 answer
63 views

Mock testing a post method which returns the location of the newly added entity and a 201 status code, using ServletUriComponentsBuilder

@PostMapping(path= "/users/{username}/events") public ResponseEntity<Object> createEventsForUser(@PathVariable String username, @RequestBody @Valid EventBean event){ event....
Prathamesh Zingade's user avatar
1 vote
1 answer
204 views

Using ThreadPoolTaskExecutor bean of appconfig in test class

I'm not able to use the bean defined in app Config in Service Test class though it works fine in Service class. How do I use the bean for test? I'm able to use executors using ReflectionTestUtils in a ...
coder87's user avatar
  • 157
2 votes
1 answer
250 views

How avoid loading unused beans in springBootTest?

I have a test class like this there I want to test only controller layer: @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class MyControllerTest { @Autowired ...
gstackoverflow's user avatar
0 votes
0 answers
34 views

Junit 5 + Mockito in every method in AuthorServicetest return NullPointerException from Modelmapper

when I execute the test method this happened: java.lang.NullPointerException: Cannot invoke "com.bookstore.com.ConfigPackage.ModelMappers.authorToDto(com.bookstore.com.domain.author.Author)" ...
Xai's user avatar
  • 21
1 vote
1 answer
139 views

UserRepository doesn't work in Spring boot tests

I'm creating an app for practice in java spring boot, but I faced with the problem when I started to test my UserService. I don't know why, but UserRepository just doesn't want to work. It initialized ...
Cross's user avatar
  • 807
0 votes
0 answers
188 views

Spring-boot wiremockserver stub junit tests not running

I am trying to make mockserver tests using wiremock for my spring api. I am just learning about it as I go. I made a test to test a post request but it wont run. Here is the test public class ...
Brendan Ahern's user avatar
0 votes
0 answers
40 views

How to defer CommandLineRunner execution in Spring Boot test

I start worker threads in CommandLineRunner component @Override public void run(String... args) throws Exception { range(0, count).forEach(i -> taskExecutor.execute(() -> { while (...
Tuomas Toivonen's user avatar
0 votes
2 answers
102 views

Under the hood of an integration tests with spring, application context manipulation

I know in the context of integration test on a spring application we can use, among others annotations: @MockBean To add mock objects to the Spring application context. The mock will replace any ...
GionJh's user avatar
  • 2,864
0 votes
1 answer
94 views

What is the service or repository to test?

I have a custom query in the repository. And the service that calls this method from the repository. I want to write a unit test. What should I test for a repository or a service? Or should I do 2 ...
WBLord's user avatar
  • 932

15 30 50 per page
1
2 3 4 5
7