Junit Category

Junit 3 vs Junit 4 Comparison

Junit 3 vs Junit 4 Overview Junit 4 is the next series of Junit 3 and introduced lot of features. It has been compatible with most tools for a while. We will compare junit 3 and junit 4 to give the difference from 11 aspects. 1. JDK Required? JUnit 4 requires Java 5 or higher, it […]

How do I implement Junit runner

Junit provides a series of junit 4 runners in the core package, for instance: org.junit.runner, JUnitCore, JUnit38ClassRunner, JUnit4ClassRunner, Parameterized and etc. these Junit runners are used to centralize and execute your test cases, JUnit4 is the default one If no customized runner annotated, our needs is to implement a customized Junit runner, in this how-to, we guide how do I write a custom […]

Junit and Ant

Junit and Ant Overview Junit and Ant are respectively Java standard unit testing framework and command-line tool, most of the time, we need to integrate them together for a project, in this tutorial I cover how to use Junit in ant task. To get started I assume you understand the basic knowledge and usages of Junit and […]

Junit Tutorial and Example

Junit is a most famous open source unit testing and regression testing framework in java, which was originally written by Erich Gamma and Kent Beck, it has became an industry standard framework which developers write repeatable tests and do white-box testing.

JUnit Tutorial – Suite Test

In previous tutorial we introduced how to run a single test case, however, most of the time we have to bunch same kind of cases along, this is what “suite test” stands for in Junit, a suite is a collection of test cases that are intended to be used to test a software program to show […]

Junit Time and Parameterized Test

One: Junit Time test The “Junit Time Test” means if an unit test takes longer than the specified number of milliseconds to run, the test will be terminated and marked as failed. This is an extremely useful case to test these time-consuming operations, for instance: you connect a database to retrieve items, if it has […]

Junit Ignore Test

We designed a lot of some cases which test software behavior, however, some of them might be exceptions which run into problem or even not ready to test, we’d like to ignore or skip these cases but keep no-changes to existing code base. Annotation @ignore in JUnit 4 allows a test to be differed until it is ready (or […]

Junit doesn’t only intend to ensure that code is working as expected and validate that this is still the case after code changes, it’s also capable for testing method which expects to throw desired exception. Two ways are available in Junit to test expected exception. 1. Catch the exception and assert success, if this exception was not thrown then assert fail […]

This tutorial introduces how to write testcase with Junit 4 and explains basic annotations supported in junit 4.

Junit 4 Tutorial and Example – Get Starting

Junit 4 Tutorial and example If you use Idea or Eclipse, The Junit IDE plug-in is normally included as a part of the IDE distribution. If do not using Idea or Eclipse, you can still use Junit as a standalone testing tool by downloading it from(http://www.junit.org). Creating a Junit Test case Open the IDE, create […]