All Questions
49
questions
0
votes
1
answer
166
views
How to write mockito test case for jdbcTemplate.batchUpdate in spring boot application?
In our spring boot application, I am trying to write mockito test case for batch insert operation method but its not working.
Getting below error
java.lang.NullPointerException
Suppressed.org.mockito....
1
vote
0
answers
1k
views
Pitest plugin is not detecting junit5 dependency
I'm upgrading an old application and it has the pitest plugin to improve the unit testing. Some newer tests are junit 5, so I added the junit5 plugin. However when I run the tests, it does not detect ...
0
votes
1
answer
113
views
MockitoJUnitRunner with SpringBoot 3.1.1
having this class:
@Service
@Transactional(readOnly = true)
public class PdfService {
private final AsAPIService asAPIService;
public PdfService(AsAPIService asAPIService) {
this....
0
votes
1
answer
244
views
Writing unit test for multipart file?
How to write unit test case for Multipart file?
@Data
Class Document {
String name;
byte[] byteFile;
}
@Service
public class DocService {
public Document makeDocument(Multipart file, ...
1
vote
0
answers
465
views
How to suppress staticinitialization with Junit 5 and mockito without using powermock
I am facing an issue while creating Mock objects with Mockito.static method. If the class contains any static initializers , these initializers are executing while creating mocks. I don not want to ...
1
vote
1
answer
2k
views
How to write unit test for clear all cache using cache manager
I have a method that evicts all the caches. PFB code for same:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org....
0
votes
0
answers
41
views
Can we mock methods also by by using mockito API in junit?
I am new to java, for curiosity I am asking, can I mock methods of another classes by using mockito, or only the classes I can mock. thanks in advance
0
votes
2
answers
2k
views
How to write unit test for URI create in java
Below is the method I'm trying to write unit test using junit 5
@Value("${proxy.host}")
private String endpoint;
public Request<Void> setAwsRequestGETParameter(String ...
10
votes
4
answers
15k
views
Junit (4.12) is not executing after spring-boot 2.6.2 migration
I have migrated from Spring to Spring-boot version 2.6.2. mvn clean install is successful but none of the junit(version 4.12) is executing. After few research I got to know that Spring-boot 2.4 ...
1
vote
1
answer
5k
views
How to write junit cases for @Bean for configuration classes
I have the below method in the @Configuration class and I need to write JUnit for this. Can anyone please guide me to achieve the JUnit test case?
@Bean
@Profile({"!test & !local"})
@...
0
votes
1
answer
559
views
How to write Junit for if else condition under thrown exceptions from rest template
I am new in Junit. I read basics of Mockito. I am not able to figure out how to write Junit for test code coverage.
I am using rest template calls to receive response object for requests sent.
I am ...
1
vote
1
answer
1k
views
Parameterized junit test of custom validation in springboot
I have this validator in springboot which gives error when an integer is not between 1 and 3 and i am using addConstraintViolation to print a message from properties file
public class SizeValidator ...
1
vote
3
answers
821
views
How to write Junit Test Cases in springBoot?
Thid is my mapping from my controller class , now I want to write unit test case for the same
@GetMapping(value = "/tokenSearch/{id}/{name}/{values}/{data_name}", produces = MediaType....
0
votes
1
answer
337
views
How to Test Spring MVC along with repository MongoDb
Can someone please help me with junit testing of service, controller and repository. I'm getting lots of error when I write test cases for service and controller class.
This is my service class
import ...
1
vote
3
answers
1k
views
Not able to mock a method with List type argument
I have a method like this
public int[] processData(List<Data> dataList){
//business logic
}
And I have used the following way to mock it
when(processData(anyList())).thenReturn(new int[]{1,...