Dymension
Dymension
JCHJava Community | Help. Code. Learn.
Created by Dymension on 12/26/2024 in #java-help
how to stub the method which is being called inside the constructor?
for a class im testing, it has parameterized constructor and in that there is a method being called, i tried to stub using doReturn().when.class.function but it doesnt stub it, the function always gets ran. So to stub these kind of functions is there any other way
6 replies
JCHJava Community | Help. Code. Learn.
Created by Dymension on 12/26/2024 in #java-help
in java how to use Spy for a class with no no-arg constructor
when i use @Spy annotation i get this error,
org.mockito.exceptions.base.MockitoException: Unable to initialize @Spy annotated field 'videoTranscriptService'.
Please ensure that the type 'VideoTranscriptService' has a no-arg constructor.
org.mockito.exceptions.base.MockitoException: Unable to initialize @Spy annotated field 'videoTranscriptService'.
Please ensure that the type 'VideoTranscriptService' has a no-arg constructor.
i need to use it as im mocking static classes in there, but it doesnt seem to work for classes with no no-arg constructor.
4 replies
JCHJava Community | Help. Code. Learn.
Created by Dymension on 12/23/2024 in #java-help
how do i unit test singleton classes in java?
specifically using mockito and junit
7 replies