If you’re new to Mockito and have only seen a sample or two on the Internet, you might find other examples create mock objects in different ways using the same framework. As a matter of fact, there are three (3) ways to create mock objects in Mockito.
This post shows how to capture arguments our codes passed to a mock’s method. To do this, a method must accept reference types. Then, we use Mockito.verify() method. Then, pass
This post demonstrates how loading data from an SQL script for a particular database platform. This is ideal for development stage when you need some seed data to fill in existing database tables.
This post is about truncating all tables in a MySQL database before DbUnit loads data via @DatabaseSetup. Doing it in @Before method does not work. DBUnit loads the data first via @DatabaseSetup before delegating calls to a @Before method.
This post shows how to access Spring ApplicationContext object in JUnit tests.
This post demonstrates how to get and set instance variables and invoke methods via the Reflection API using Spring ReflectionTestUtils. There are key reasons to do things via Reflection: 1) test non-public methods (not recommended, though), and 2) inaccessible instance variables (to mock).
There is a scenario to watch out for where we have class with a few instance variables of reference types but not all of them get initialized via a constructor. This post demonstrates shows how we could unknowingly miss initializing other mocks in a class and how to fix them.
This post demonstrates how to reuse our unit tests with JUnit Parameterized. Let’s say, we have a JUnit test class that tests for, for example, a single web browser’s “browse-to-URL” functionality in various scenarios and we want to reuse those tests for other browsers with the least code change.
This post demonstrates how to perform repeated tests in JUnit 4 for this post. It involves creating a class that implements the TestRule interface, another class that implements Statement interface and a new annotation.
Grouping Unit Tests [wp_ad_camp_5] At times there are certain set of unit tests we want to execute automatically. These tests may be critical or have been simply grouped for some