Skip to content

Tag: mockito

Spring value injection in mockito

I’m trying to write test class for the following method I’m using the injected url value in one of the methods in the class. To test this i’ve written a junit class In applicationContext-test.xml I’m loading the property file using But the url value is not getting loaded in the CustomS…

Testing Private method using mockito

How to test private method is called or not, and how to test private method using mockito? Answer You can’t do that with Mockito but you can use Powermock to extend Mockito and mock private methods. Powermock supports Mockito. Here’s an example.

Using Mockito’s generic “any()” method

I have an interface with a method that expects an array of Foo: I am mocking this interface using Mockito, and I’d like to assert that doStuff() is called, but I don’t want to validate what argument are passed – “don’t care”. How do I write the following code using any(), t…