-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce build duration by lowering Mockito usage #2707
Comments
Yes. This makes sense. I would agree to Mockito replacements if:
This will likely result in some duplication but that is an acceptable tradeoff. |
Does someone made a study to use another mock library to see if there will be better performance ? (EasyMock/JMockit/...) |
I didn't tried with other mock library. The proposed solution #2767 replaces mockito by stub and fake implementations, which leads to a 7% improvement of the build time (that is, much more than the 2% expected). |
I understand the principle of using fake implementation. However, I think that if you have an interface with 25 methods, the test class will be poluate with a lot of fake implementation, with also a lot unuse code. That is why I questioned the use of other library |
I agree that readability is generally lower when using stub classes with a lot of methods... This may be improved by having specific stub classes that are shared between test cases, but @mpkorstanje wanted stubs implementations to be declared in the test class. I didn't found a lot of mocking libraries performance comparisons, but according to mockito/mockito#3288, mockito and Easymock have more or less the same performance. |
🤔 What's the problem you've observed?
Mockito has a impact on the unit test execution time (seen using IntelliJ Profiler flame graph):
Total build duration: 3min17 = 197 seconds
Total test duration : 23.5 seconds
Total Mockito contribution : 4.2 seconds (18% of tests, 2% of build duration)
By reducing the usage of Mockito, the test duration can be lowered with two advantages:
✨ Do you have a proposal for making it better?
I didn't check in details, but for example in
JavaBackendTest
, the@Mock
ObjectFactory
andGlue
could be replaced by fake implementations, which could reduce the class test duration by about 80%.The text was updated successfully, but these errors were encountered: