Skip to main content
Filter by
Sorted by
Tagged with
0 votes
1 answer
210 views

I want to mock a complex case of Java method response into JUnit 5 test which is using hateoas. The JUnit 5 test: @ExtendWith(MockitoExtension.class) public class ReportingATest { @Spy protected ...
Peter Penzov's user avatar
  • 1,074
0 votes
0 answers
22 views

This is my simple viewmodel @HiltViewModel class SplashViewModel @Inject constructor( checkRemoteConfigUseCase: CheckRemoteConfigUseCase, private val navigator: Navigator, @EntryPoint(...
lou_dani's user avatar
1 vote
1 answer
151 views

I'm trying to verify calls to a Kotlin extension function using Mockito, but I'm encountering an issue where the test is counting internal property accesses rather than the actual function call. Here'...
Mohammad Esteki's user avatar
0 votes
3 answers
3k views

I am trying to test Spring Boot's Rest controller. Problem: I am using @MockitoBean annotation for mocking the ContactService.java class. The Rest controller depends on this ContactService.java class. ...
Yousaf's user avatar
  • 29.5k
0 votes
0 answers
68 views

I want to write some UI tests for a Composable screen. I constantly facing the same error again and again. The viewmodel cannot be mocked, even though I have declared the viewmodel class as open. here ...
Nontas Papadopoulos's user avatar
0 votes
1 answer
40 views

I need to make a mock that says something like object.name = "Object 1"; when(some_method(object)).thenReturn(someValue) Being object an instance of an object with certain specific fields, ...
Nisanio's user avatar
0 votes
1 answer
57 views

Hi! I'm Unable to mock fetching data from GitHubApi To fetch data i use RestTemplate Exchange Instead of taking data from github i want to mock my own Expected :1 Actual :11 Fetch Logic: @Component ...
pmalys's user avatar
  • 15
0 votes
0 answers
63 views

I have tried everything for hours and don't seem to be able to make tests work: // this is taken from https://github.com/aissat/easy_localization/issues/359 // more on this below class ...
Fi Li Ppo's user avatar
  • 320
0 votes
1 answer
127 views

I am trying to mock a method and want to execute the internal logic as is when called. The method returns void so When I am using when(MockedObject.methodReturingVoid(any())).callRealMethod(); It ...
Jef's user avatar
  • 144
0 votes
0 answers
57 views

I have a SpringBoot Service class. I am writing Junit for one of the method which internally calls multiple method of the same class. Internal method also calls another method. I tried using when-...
B Chitra's user avatar
1 vote
0 answers
79 views

I want to test a method that creates an ArrayList<String>. I want to capture what it puts into the list. How do I create a MockedConstruction<ArrayList<String>>? For example: try(...
berger-devel's user avatar
0 votes
0 answers
51 views

I am trying to write a JUnit test for my Android project. I am using the Android junit:4.13.2 and Mockito org.mockito:mockito-core:5.15.2 dependencies. Here is the gradle sourceSet which I have used ...
Raj's user avatar
  • 506
1 vote
1 answer
160 views

I'm having problems testing/mocking an IOException when using a Reader. Code: public class Loader { public static void load(Reader reader) { try (BufferedReader bufferedReader = new ...
ashamedgap's user avatar
-2 votes
2 answers
480 views

I am trying to write a unit tests for a class that has a variable value set to System.getEnv("..."). Now I am getting initialization error when running the test class. I've tried mocking the ...
Aakash_Deep's user avatar
0 votes
0 answers
43 views

I am trying to write a unit test case of success for firebase password less sign-in but getting null pointer exception and error that sendSignInLinkToEmail(...) must not be null. @Mock private ...
Rameez Khan's user avatar
0 votes
2 answers
197 views

I have a bean like this: @ApplicationScoped public class MyService { @Inject @All List<MyDataProvider> dataProviders; public List<String> getAllData() { var data = ...
Ultranium's user avatar
  • 372
1 vote
1 answer
89 views

In the setup in my test, the line: when(kc.getToken()).thenReturn(token); does not work and I get the following error from the ServiceImplementation: java.lang.NullPointerException: Cannot invoke &...
joan's user avatar
  • 23
0 votes
2 answers
43 views

I was asked if this code connects to a database or not. I am not seeing @Mock annotation or @MockBean annotation so I said that it does fetch data from database. Was my answer correct? @DisplayName(&...
Amy's user avatar
  • 3
2 votes
1 answer
60 views

The following JUnit Jupiter Tests with Mockito are working fine: @Test void testVerifMethod() { System.out.println("*** Start test verify method ***"); mockedList....
tarekahf's user avatar
  • 1,082
0 votes
1 answer
45 views

I am facing a issue that even my Junit class doesn't give an error, Eclipse doesn't run my junit test(I am super new in Junit Testing but, i guess eclipse doesn't recognize my junit test methods. here ...
Salih Can Aydogdu's user avatar
0 votes
0 answers
80 views

I was doing some testing and I can't get it right. I was making some tests using mockito and jqwik and I wanted to assert if a method was being called exactly 5 times for that I used the function @...
Luis Santos's user avatar
0 votes
1 answer
64 views

SomeClass instance = someService.getSomething.apply("by-something"); above statement is being used in controller to fetch data. I want to test controller. So i am mocking above line in test ...
Indresh Mahor's user avatar
1 vote
1 answer
49 views

Does it make sense to write assertNotNull(mockObject) in header of test method body? When is a null check necessary for a mocked object? @ExtendWith(MockitoExtension.class) class SomeTest { @Mock ...
sunvis0r's user avatar
0 votes
0 answers
74 views

tests working in mockito 4.x are not working with mockito 5.x getting error after migrating spring from 2.7 to 3.1.4. Error: Suppressed: org.mockito.exceptions.misusing.InvalidUseOfMatchersException: ...
shogv48's user avatar
1 vote
0 answers
42 views

I have migrated our multi-module Gradle project from Mockito v1 to Mockito v3. As part of the migration, the following libraries were upgraded or added: mockito-core from 1.10.19 to 3.12.4 (and added ...
seened's user avatar
  • 43