Question:
I want to mock the static method being invoked from the constructor of my class.My class:
NodeUtils.java Class:
Since I am new to Java I am not able to catch this. Any help here is appreciated.
Answer:
So to answer your question how to mock a static method: mockito allows this since version 3.8.0. You can find a tutorial here at BaeldungThis allows generating a statically mocked Object for a concrete context, which you can create within a try block. For your case this would look like the following.
Fixed Unit Test
You need mockito with at least version 3.8.0 in your project.
With maven add:
If you have better answer, please add a comment about this, thank you!