All Questions
4,821
questions
0
votes
0
answers
26
views
How to write verify for static methods that have been called [in Mockito Core] [duplicate]
Without using PowerMockito and using Mockito-Core (the version of Mockito doesn't support PowerMockito and I cannot change the Mockito version), How can I verify that a call to a static method has ...
1
vote
0
answers
27
views
JerseyTest and Mockito - problem with mocking an object
My aim is to learn a little bit about mocking objects in the context of Jersey Test.
I have 3 classes:
ServiceController
package com.vogella.jersey.first;
import javax.ws.rs.*;
import javax.ws.rs.ext....
0
votes
1
answer
44
views
Stubbing error while mocking WebClient using Mockito
Based on answers to previous questions like these, I am trying to mock WebClient in a unit test. Please note that I don't wish to use WireMock or MockWebserver.
source method:
public class ...
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 ...
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&...
-1
votes
2
answers
63
views
How to write a unit test with a controller method that has protected code in it [duplicate]
I am trying to write a unit test for the following controller:
@RestController
@RequestMapping(value = ENDPOINT_URL)
public class MainController extends RestControllerBase {
MainService ...
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 ...
1
vote
1
answer
23
views
Java unit test failing due to null KeyHolder
I'm creating new unit tests for an application and I'm stuck because the KeyHolder is not returning a valid object.
For context, here are my classes:
ScriptDao class:
@Repository
public class ...
0
votes
0
answers
32
views
In Java, using Mockito fails to initialize MockMaker plugin
When I try to run this code:
package __6__240703.test.user_repository;
import static org.mockito.Mockito.*;
import static org.junit.jupiter.api.Assertions.*;
import __6__240703.main.user_repository....
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) {
...
0
votes
0
answers
29
views
Junit Mockito Testcase for Rest API controller class taking boolean as path parameter
I am new to Junit Mockito testcase. I am trying to write REST API controller class .But facing some issue.Can someone please help me on writing the test case.
@RestController
@RequestMapping("/...
0
votes
1
answer
49
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 (...
0
votes
1
answer
37
views
Junit Mockito testcases for Service Layer
I am facing issue while writing junit mockito testcases for the below service layer class. Can someone help me writing the test cases for me.
public class BigQueryServiceImpl implements ...
0
votes
0
answers
34
views
I created a test case method named 'testRegisterCustomerSuccess,' but it encountered issues related to JPA queries
I have a method named registerCustomer in a service implementation class. I created a test case named testRegisterCustomerSuccess for this method in a class named UserServiceImplTest, where I mock ...
0
votes
0
answers
27
views
Android test class with time delay
I'm working on an IdleHandler class in my Android app to handle inactivity. The class looks like this:
class IdleHandler {
object TimerConstants {
const val ...