Category "mockito"

Mockito mockStatic cannot resolve symbol

I'm using Spring Boot and in a unit test, I'm trying to mock the Files.delete(myFile.toPath()) method. To do so I'm trying to use the Mockito.mockStatic() metho

"Bad state: Cannot call `when` within a stub response", "type 'Null' is not a subtype of type [...]"

I wrote a few unit and widget tests for my Flutter app. They all pass when called from the testing window out of VSCode: But when I call flutter test from the

Strict @MockBean in a Spring Boot Test

I am developing a Spring Boot application. For my regular service class unit tests, I am able to extend my test class with MockitoExtension, and the mocks are s

Because testing_app requires SDK version >=2.16.1 <3.0.0, version solving failed. in flutter

I am learning more about testing and i want to use Mockito Package and Build Runner Packate then i have my class Cat inside lib/models/cat.dart then i have my

Java | Mutation Testing | PiTEST | (negated conditional → SURVIVED) | (changed conditional boundary → SURVIVED)

I am getting piTest issues. Few mutations are getting survived. PiTEST negated conditional → SURVIVED changed conditional boundary → SURVIVED As per

How do I mock a static void method (not with doNothing or invocation -> null) using Mockito.mockedStatic?

I have the following classes class FileDownloader { public static void downloadFile(String repoUrl, String filename) throws IOException { // Downloa

error when Add a stub for a method using Mockito's 'when' API

Have this abstract class to get data from remote data source abstract class NumberTriviaRemoteDataSource { /// Calls the http://numberapi.com/{number} endpoin

Android Mockito test cases with Retrofit

I am new to test cases and I am trying to write test cases for the below code but I did not get success after trying several method. My main target is to cover

How to get mock final classes mock-maker-inline to work?

I'm having issue getting the mock-maker-inline to work. I followed the instructions on However, i still can't mock out a final class. I also tried out the

Mockito Matcher for a TypeReference

I am trying to write a Java unit test using Mockito but am having trouble to get a matcher to work. I want to test the following class CustomService.java pub

Is there an equivalent of verifyZeroInteractions() for verifying an exact number of interaction with a mock object?

I would like to verify there were exactly x interactions with might db mock object. Is there something similar to the 'verifyZeroInteractions()' method for doin

Mock call to static method of a utility class

I need to write a unit test for the method processNotification. But this method internally calls JsonUtility.getNotificationDTOFromMessage. I need the return

org.powermock.api.mockito.ClassNotPreparedException when it's declared to be prepared

I don't understand why this is showing since my test definitely asked PowerMock to prepare for it. @PrepareForTest({AmazonSQSClientBuilder.class}) @RunWith(Powe

How to avoid jwt token or ignore authentication when testing HTTP API request?

mvc.perform(MockMvcRequestBuilders.get("/PensionerDetailByAadhaar?aadhaarNumber=123").header("Authorization","Bearer "+token)).andExpect(status().isOk()); Here

Why can't mock static method in Spring condition

this is my code. class ACondition extends SpringBootConditoin { public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata meta

Mockito mock Java @Value with spring boot

Hi I have this simple code for my Spring Boot Project: @Component public class UserRowMapper implements RowMapper<User> { @Value("${bug.value}") p

@TestPropertySource is not helping to fetch configuration property values

In the following test code snippet, values of number_of_days.last and number_of_months.plan are not getting fetched from the configuration file.Please check and

Test Fails with "when() requires an argument which has to be 'a method call on a mock' " error on maven project(no frameworks used)

Hi I am trying to mock an insertion in my database and run it for a test. The test is failing with and error "when() requires an argument which has to be 'a met

Test Fails with "when() requires an argument which has to be 'a method call on a mock' " error on maven project(no frameworks used)

Hi I am trying to mock an insertion in my database and run it for a test. The test is failing with and error "when() requires an argument which has to be 'a met

How to test Kafka OnFailure callback with Junit?

I have the following code to send data to Kafka: @Service public class KafkaSender{ @Autowired private KafkaTemplate<String, Employee> kafkaTempla