All Questions
975
questions
-3
votes
1
answer
64
views
My when(...).thenReturn(...) is not working [closed]
I'm making some test but my mocking is not working.
This is my test class.
@UnitTest
@RunWith(MockitoJUnitRunner.class)
public class ResendMailingStrategyUnitTest {
@Test
public void sendTest(...
0
votes
0
answers
52
views
How to Test Apache Camel Route with RoutePolicy without Modifying Route Code?
I am working on testing an Apache Camel route that utilizes a RoutePolicy. The route code is as follows:
from("direct:test")
.routeId(IMPORT_AGENTS_REFERENTIAL)
....
0
votes
0
answers
39
views
How to mock a static method that modifies an input and returns Unit with Mockk
I'm trying to use Mockk to mock the static method android.location.Location.distanceBetween().
Here's my test case:
class DistanceUtilsTest {
@Before
fun setup() {
MockKAnnotations....
0
votes
1
answer
37
views
Junit and Mockito how mock class being instantiated with mocked parameter
I'm not super familiar with mockito. I am trying to mock the results of a class that is being instantiated within another class.
public class TestClass {
@Test
public void testSomething() {
...
0
votes
2
answers
40
views
Mockito service dependency null pointer exception
So, let me show my problem. I have Service class:
@Service
@Transactional
public class UserServiceImpl implements UserService {
private final UserRepository userRepository;
private final ...
0
votes
0
answers
11
views
ViewModel Until test case error Provider members initialize error
I am getting provider initial error while trying to run viewModel test case
Provider members initialize error
com.venuetize.vzsportsapp.providers.Provider$ProviderException: Provider members ...
0
votes
0
answers
55
views
Why this mocked StringBuilder always return the string "stringBuilder" ? Posibly confiusion with Junit mocks
Hello and sorry for my english. Im new in Junit and im trying to learning mocks and how it works, well, I have this test class with the next mocks:
@DataJpaTest
@AutoConfigureTestDatabase(...
0
votes
0
answers
44
views
Exception not getting translated
I have a method that makes a HTTP call like so:
public String executeRequest(HttpRequest request) {
try {
return httpResourceProvider.getHttpClient()
.send(request, HttpResponse....
0
votes
0
answers
44
views
Integration Testing using Junit Patch and Delete end point work but get does not
Using junit5, Java21
@Tag("IntegrationTest")
@ExtendWith(SpringExtension.class)
@WebMvcTest(controllers = ReasonsController.class)
public class ReasonsControllerIntegrationTest {
...
0
votes
0
answers
385
views
Quarkus RestClient unable to mock method with multiple @Consumes content-types
I'm currently trying to mock a Quarkus @RestClient which is generated from an OpenApi spec. This RestClient contains the following method:
@PATCH
@Path("/{id}/")
@Consumes({"...
0
votes
0
answers
172
views
Mockito 5.0.0 Static Mocking Exception
I am getting the following exception when trying to mock the static method.
static mocking is already registered in the current thread To create a new mock, the existing static mock registration must ...
0
votes
0
answers
53
views
Error when running unit test with mock - "when() requires an argument which has to be 'a method call on a mock" [duplicate]
I have looked at many SO questions and answers on this error and tried the solutions specified, but had no luck so far. So the issue is "when() requires an argument which has to be 'a method call ...
0
votes
2
answers
278
views
Mocking using @Mock annotation is not working for my junit test case
I have been Unit testing a class where when I use @Autowired the testing class one of the test methods passes and the other test methods fails, when I use @Inject mocks instead of @Autowired the ...
0
votes
0
answers
167
views
How to test a private variable inside a method using Mockito or Junit
I wish to write a test which can confirm that the private title variable will equal "internet connection lost please try again"
var title = ""
if (errorMessage.equals("...
1
vote
0
answers
34
views
Unable to cover Consumer function in code coverage for ReceiverOptions.addAssignListener()
I have been trying to increase code coverage on this particular piece of code for a while but can't seem to figure it out. This private method is invoked from within a public method. The public method ...