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
Can mock construction of 'new File()' with Mockito.mockConstruction #2342
Comments
I took a look at the issue, and it seems to loop at Consider the following test:
EXPECTED BEHAVIOUR: both test pass
After that, I changed the definition of Foo class to match the structure of File:
Strangely, now BOTH tests pass (assuming testFoo is launched before testFile). I debugged each test separately and for
For
My setup: Dependencies:
|
If the File or URL classes are changed by mockConstruction() the MockMethodAdvice.isOverriden() is called. if (methodGraph == null) { To load the ForLoadedType class the URLClassPath.getResource() method is called. The body of this method contains File and URL objects. |
Do you think mockito should resolve the issue or do we have workaround to mock 'new File()'; |
Unfortunately, |
Hello,
I can't use Mockito.mockConstruction to mock the construction of 'File'.
https://stackoverflow.com/questions/68097251/can-the-mockito3-mockconstruction-make-stub-on-new-file
It's better to have a way to return mock object or real object from the 'mockConstruction'.
The text was updated successfully, but these errors were encountered: