Tags » JUnit

Pragmatic Programming in Java 8 with JUnit

Jeff Langr recently put out a new book Pragmatic Unit Testing in Java 8 with JUnit which I highly recommend. I’ve recently come back to Java (mostly through teaching XP courses) and wanted a refresher on some unit testing best practices. 235 more words

Agile

An adapter to use Hamcrest matchers as AssertJ conditions

Following on from yesterday’s post on AssertJ, here’s a tiny github repo that I put together with some utilities for AssertJ.

The first is the script mentioned yesterday, tidied up a little and renamed. 66 more words

Converting from Hamcrest to AssertJ

Don’t quite know how I missed it all these years, but I only recently discovered AssertJ.  So I’ve started to use it in some of the… 121 more words

JUnit Basics

— Open source framework to write , organise and run test cases.

—  A Framework has scripts, excel sheets, logs , repositories etc. To use all of these together, we need a central controller which can be done using JUnit or TestNg. 599 more words

Testing

Understanding JUnit method order execution

With the addition of the ClassRule annotation in JUnit 4.9, I thought I’d come back and revisit JUnit test order execution.

@ClassRule fills a gap in the JUnit API, by providing class level rules like… 2,028 more words

LZH reblogged this on TechCentral and commented:

Great post on junit method order execution

The Power of thenAnswer

Syntax:

when(myMock.method(myObject)).thenAnswer(Answer<?> answer);

or

doAnswer(Answer<?> answer).when(myMock).method(myObject);

Use case 1:

You can mock/stub void methods (as i explain in this post) to simulate the behaviour of them, which then will i.e. 728 more words

Mockito

Mockito Deep Stubs Example

This tutorial tries to explain how to use Mockito’s Deep Stubs feature.

When you’ve situations where your class under test has multiple levels of dependencies, … 322 more words

Java