Understanding the Definition of the mock Class to Use with Junit

Asked 2 years ago, Updated 2 years ago, 113 views

Uses a mock function called setReturnValueAt in the test source for the java source.Does the mock class need to define setReturnValueAt?

junit mock mockito

2022-09-30 20:24

1 Answers

If you search setReturnValueAt, it is introduced as DJUnit code, not JUnit.Is DJUnit syntax acceptable? I don't think jUnit alone provides Mock.
If DJUnit is, first of all, the development of DJUnit has already stopped, and it is not easy to follow Java 7 or later specifications.This kind of library will be affected when Java 8 changes the specifications, so I've been urged to deal with it, but I don't think so either.
Currently, it is common to use Mockito.
動作I am afraid that I will not be able to use the test code when I change the specifications of Java in the future, so I will be suspicious of collecting the cost of creating the test code.

Also, as Yukihane said, the setReturnValueAt method does not need to exist in the mocking target code.
(There is no point in separating the test target from the test code.)


2022-09-30 20:24

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.