Category Archives : JUnit

Home  >>  JUnit

How to Replace Rules in JUnit 5

On April 6, 2016, Posted by , In JUnit, By ,,,, , With 11 Comments

The recently published JUnit 5 (aka JUnit Lambda) alpha release caught my interest, and while skimming through the documentation I noticed that rules are gone – as well as runners and class rules. According to the user guide, these partially competing concepts have been replaced by a single consistent extension…

JUnit 5 – A First Look at the Next Generation of JUnit

On February 18, 2016, Posted by , In JUnit,Spotlight, By , , With 3 Comments

In the beginning of February, the JUnit 5 (aka JUnit Lambda) team has published an alpha release. Since JUnit 4 is among the most used items in my toolbox I thought it might be worth to have a look at the next major release. I took the latest build for a spin…

Testing with JUnit: E-Book Xmas Offering for Less than 6$

On December 22, 2015, Posted by , In JUnit, With Comments Off on Testing with JUnit: E-Book Xmas Offering for Less than 6$

Long story short, my publisher has informed me about a campaign that started on December 17th and which is lasting into the new year. Packt Publishing is inviting the tech world to explore its extensive library of e-books and video courses for one amazing price. Every single e-book and video…

What the Heck Is Mutation Testing?

On October 5, 2015, Posted by , In JUnit,Spotlight, With 8 Comments

In recent times, I came repeatedly upon the term mutation testing. Since the word is that this approach is able to detect test safety net gaps in a way which goes beyond code coverage, I took my time to catch up on the topic and gave it a try. This…

Clean Integration Testing with JUnit Rules

On September 28, 2015, Posted by , In JUnit, By ,,,, , With Comments Off on Clean Integration Testing with JUnit Rules

The benefits of JUnit Rules, especially when dealing with integration testing, can hardly be overrated. In this post, we’ll shine a light on the usefulness of ExternalResource extensions. These simplify fixture control in cases where we have to work with external-resource-abstracting third-party libraries. As an example, we’ll have a look…

Testing with JUnit Book Release

On August 31, 2015, Posted by , In JUnit, By ,,, , With 1 Comment

This week, I’m very happy to break the news that Packt Publishing has come out with a JUnit book release, fresh from the press. The title Testing with JUnit, which I had the privilege of writing, is now available in the bookstores. It has been quite some work, but I…

Testing with JUnit Book Announcement

On June 25, 2015, Posted by , In JUnit, By ,,, , With Comments Off on Testing with JUnit Book Announcement

Today, I am very pleased to inform you that Packt Publishing has put out a JUnit book announcement called Testing with JUnit on their website. A couple of months ago I was asked to write a book about one of my favorite topics – testing with JUnit. Needless to say…

OSGi Service Test Helper: ServiceRegistrationRule

On February 11, 2015, Posted by , In JUnit,OSGi, By ,,, , With Comments Off on OSGi Service Test Helper: ServiceRegistrationRule

OSGi Service Tests can be an efficient means to avoid problems related to dangling service references. As promised in my post about writing simple service contribution verifications, this time I introduce a JUnit rule that assists in testing interactions between components. OSGi Service Tests for Component Interaction Assume we have…

OSGi Service Test Helper: ServiceCollector

On February 5, 2015, Posted by , In JUnit,OSGi, By ,,, , With Comments Off on OSGi Service Test Helper: ServiceCollector

OSGi services come in handy for the development of systems based on loosely coupled components. But loose coupling can make it difficult to recognize problems related to dangling service references. Thus we usually run integrations tests to ensure the availability of service components at runtime. With the intention to reduce…

OSGi Testsuite: Introducing Classname Filters

On November 12, 2014, Posted by , In Eclipse,JUnit,OSGi, By ,, , With 4 Comments

OSGi Testsuite is a JUnit test-runner that collects dynamically test classes for execution. It has been published by my fellow Rüdiger about a year ago and proven useful in some projects already. However for gonsole we had to use an ugly patch because version 1.0 only supported .*Test postfix matching…

Lightweight Integration Tests for Eclipse Extensions

On November 3, 2014, Posted by , In Eclipse,JUnit, By ,,,, , With Comments Off on Lightweight Integration Tests for Eclipse Extensions

Recently I introduced a little helper for Eclipse extension point evaluation. The auxiliary strives to reduce boilerplate code for common programming steps, while increasing development guidance and readability at the same time. This post is the promised follow-up that shows how to combine the utility with an AssertJ custom assert…

Clean Unit Test Patterns – Presentation Slides

On October 27, 2014, Posted by , In JUnit, By ,, , With Comments Off on Clean Unit Test Patterns – Presentation Slides

I was given the opportunity to talk at the GDG DevFestKarlsruhe 2014 conference about ‘Clean Unit Test Patterns’. Thanks to the organizers for inviting me and thanks to all people listening to my talk. As promised I shared the presentation e.g. for those who want to have a look at…

JUnit in a Nutshell: Yet Another JUnit Tutorial

On September 24, 2014, Posted by , In JUnit, By ,,, , With 2 Comments

Why Another JUnit Tutorial? JUnit seems to be the most popular testing tool for developers within the Java world. So it is no wonder that there have been written some good books about this topic. But I still meet quite often programmers, who at most have a vague understanding of…

JUnit in a Nutshell: Unit Test Assertion

On September 10, 2014, Posted by , In JUnit, By ,,, , With 2 Comments

The last chapter of my multi-part tutorial about JUnit essentials covers various unit test assertion techniques. It elaborates on the pros and cons of the built-in mechanism, Hamcrest matchers and AssertJ assertions. The ongoing example enlarges upon the subject and shows how to create and use custom matchers/assertions. Unit Test…

JUnit in a Nutshell: Test Runners

On September 3, 2014, Posted by , In JUnit, By ,,, , With 4 Comments

The fourth chapter of my multi-part tutorial about JUnit testing essentials explains the purpose of the tool’s exchangable test runners architecture and introduces some of the available implementations. The ongoing example enlarges upon the subject by going through the different possibilities of writting parameterized tests. Since I have already published…

JUnit in a Nutshell: Test Isolation

On August 27, 2014, Posted by , In JUnit, By ,,, , With 1 Comment

Chapter three of my multi-part tutorial about JUnit essentials discusses the implications of unit dependencies for testing. The post illustrates the test isolation principle and shows how it can be put into practice – based on the nomenclature defined by Meszaros in xUnit Test Patterns [MES]. The ongoing example continues…

JUnit in a Nutshell: Test Structure

On August 18, 2014, Posted by , In JUnit, By ,,, , With 4 Comments

Chapter two of my multi-part tutorial about JUnit testing essentials will continue the ongoing example and work out the common structure that charactarizes well written unit tests. The nomenclature used throughout this post was defined by Meszaros in xUnit Test Patterns [MES]. The Four Phases of a Test The tutorial’s…

JUnit in a Nutshell: Hello World

On August 12, 2014, Posted by , In JUnit, By ,,, , With 5 Comments

JUnit in a Nutshell is a multi-part tutorial about the essentials of JUnit testing. This Hello World chapter introduces the very basics of a test: how it is written, executed and evaluated. The post also kicks off the ongoing example, which is continuously carried forward throughout this mini-series. Why bother?…

Clean JUnit Throwable-Tests with Java 8 Lambdas

On July 28, 2014, Posted by , In JUnit, By ,,,, , With 7 Comments

Recently I was involved in a short online discussion on twitter and google+ which concerned the question why the arrival of Java 8 Lambda expressions makes the catch-exception library1 obsolete. This was triggered by a brief announcement that the library won’t be longer maintained as lambdas will make it redundant….

A JUnit Rule to Run a Test in Its Own Thread

On July 21, 2014, Posted by , In JUnit, By ,,, , With 2 Comments

In JUnit it could be occasionally helpful to run a test in its own thread. In particular when writing integration tests that interact with encapsulated ThreadLocals or the like this could come in handy. A separate thread would implicitly ensure that the thread related reference of the threadlocal is uninitialized…