Home » Tag Archives: JUnit

Tag Archives: JUnit

Expected Exception Rule and Mocking Static Methods – JUnit

Today I was asked to consume a RESTful service so I started implementing it following Robert Cecil Martin’s rules for TDD and came across a new way (atleast for me) of testing the expected exception along with the error message so thought of sharing the way I implemented it as part of this post. To start with let’s write a ...

Read More »

Data driven testing with Junit & easytest

In this article we are going to see how can we make a Data Driven testing with Junit. For this I am going to use a library called EasyTest. For TestNG , as we know, it has built in data provider. Using easy test, we cam use Junit to do data driven tests. What is Data Driven Testing? When you ...

Read More »

Using Kafka with Junit

One of the neat features that the excellent Spring Kafka project provides, apart from a easier to use abstraction over raw Kafka Producer and Consumer, is a way to use Kafka in tests. It does this by providing an embedded version of Kafka that can be set-up and torn down very easily. All that a project needs to include this support is ...

Read More »

Create JNDI resources for JUnit testing using Spring

Until recently, I had static methods setting up my in memory database (HSQLDB). I called these methods in setUp/tearDown of my JUnit tests. This felt always a bit unnatural to me as I use Spring and everything should run through it’s application context. Creating a simple JNDI bean As I use JNDI in production, I had to created a JNDI ...

Read More »

JUnit vs TestNG: Which Testing Framework Should You Choose?

JUnit vs TestNG: The testing frameworks showdown Testing is an inseparable part of the software release cycle in well balanced developer teams. And it wasn’t always like that. Unit tests, integration test, system tests and others weren’t always around. Today, we’re lucky to be in a place in time where testing matters and the value is known to most of ...

Read More »

JUnit 5 – Dynamic Tests

When it came to defining tests, JUnit 4 had a tremendous weakness: It had to happen at compile time. Now, JUnit 5 will fix this oversight! Milestone 1 just got released and it comes with the brand-new dynamic tests, which allow the creation of tests at run time. Overview Other posts in this series about JUnit 5: Setup Basics Architecture ...

Read More »

JUnit 5 – Conditions

We recently learned about JUnit’s new extension model and how it allows us to inject customized behavior into the test engine. I left you with the promise to look at conditions. Let’s do that now! Conditions allow us to define flexible criteria when tests should or shouldn’t be executed. Their official name is Conditional Test Execution. Overview Other posts in ...

Read More »

JUnit 5 – Extension Model

We already know quite a lot about the next version of Java’s most ubiquitous testing framework. Let’s now look at the JUnit 5 extension model, which will allow libraries and frameworks to add implement their own additions to JUnit. Overview Setup Basics Architecture Extension Model Conditions Injection … Most of what you will read here and more can be found ...

Read More »

JUnit 5 – Architecture

Now that we know how to set JUnit 5 up and write some tests with it, let’s take a look under the covers. In this post we’ll discuss the JUnit 5 architecture and the reasons why it turned out this way. Overview This post is part of a series about JUnit 5: Setup Basics Architecture Conditions Injection … JUnit 4 ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns