I'm new to Java unit testing and have a question about mocking.
I have a 3rd party library that checks whether network interfaces are active. But I want my unit tests to be transferable to another machine (where that machine may have a different interface setup).
I think that mocking may be the answer so that I can create my basic implementation of the library and return the values that I choose to exercise my code.
What is the easiest way of mocking a 3rd party library? I would like to avoid using libraries such as JMockit as I want to keep my test setup simple.
Thank you!
答案 0 :(得分:1)
Using libraries like JMockit and Mockito are there to keep things simple - you do all your test setup within the test class itself, and then it can run in isolation, anywhere you like.
Investigate which of the mocking libraries you prefer, and then implement your tests in it - you'll be glad you did, as using a mocking framework is an excellent skill to possess.