Tags » Mockito

Mockito & DBUnit: Implementing a mocking structure focused and independent to your automated tests on Java

Hi, my dear readers! Welcome to my blog. On this post, we will make a hands-on about Mockito and DBUnit, two libraries from Java’s open source ecosystem which can help us in improving our JUnit tests on focus and independence. 4,086 more words

Java

Powermockito behaving differently on debug

Another issue that took me a long time to figure out. I had a failing test, so I started to investigate the issue with the debugger. 209 more words

Java

When to use Mockito Spy?

If we only need to mock several methods of a class leaving the rest free to respond to calls normally, we cannot mock it, we have to spy it. 318 more words

Junit

Evaluation with Mockito Matchers and ArgumentCaptor

There are many ways of testing a method. I will list here some trivial examples testing my method using Mockito Matchers and ArgumentCaptor; each of them has %100 coverage, but are getting more clever each time. 450 more words

Junit

How to ensure quality of JUnit tests?

Besides code review, the code coverage (line or/and branch) is also often considered as a medium for measuring the quality of unit tests. From my experience, this leads to developers adding some tests (let’s say it like useless tests) just to be sure their coverage result is enough. 1,265 more words

Junit

Tutorial: Java abstract classes testing

In Java, abstract classes are used to define the interface of the class, with a list of (abstract) methods to be implemented by the extending class; basically what it is also possible to have with the “real” interfaces, the one defined with the interface instruction. 2,218 more words

Java

Mockito - Partial Mocks - mock() and spy()

Mockito.mock

Ok so say I have two methods in my class –

public class ToBeMocked {

    public String methodOne() {
        return "methodOne calls methodTwo - " + this.methodTwo();
    }
    	   
    public String methodTwo() {   
        return "Hi Im methodTwo";
    }

}
… 244 more words
Mockito