Skip to content
Advertisement

How to write JUnit 5 test cases for the following code?

This is the method to write the JUnit test cases for

JavaScript

Inside the LoanApiCallEntity class these are the following:

JavaScript

This is the test case I have tried, but it shows an error:

JavaScript

The error shown while running the project (mvn test) is – LoanApiCallEntity cannot be returned by getAllApiCallDetails().

Advertisement

Answer

getAllApiCallDetails() returns a list of objects so you need to provide a list as a mock value in the doReturn function call.

Advertisement