Tags » JUnit

JUnit - How to collect multiple assertion results in one test

If you attempt to perform multiple assertions in a test, JUnit stops at the first failed assertion.

Let’s take a look a this code:

Assert.assertEquals("First assert",4, 3+3);
Assert.assertEquals("Second assert",4, 2+2);
Assert.assertEquals("Third assert", 5, 3+1);
Assert.assertEquals("Third assert", 7, 5+2);
… 173 more words
Senza Categoria

JUnit Rule + Java 8 Repeatable Annotations == Clean Tests

Last couple of months I am spending most of my free time writing Docker Java REST API client using RxJava and OkHttp. I have been following TDD for developing this API. 984 more words


Spring Boot + JBehave follow-up

After my last post I needed to add some configurations to the Embedder in JBehave. The examples I found all edited the Embedder in the JUnitStories constructor however this did not work for my Spring Boot tests due to the… 41 more words


JUnit - Parametric testing

Sometimes we need to perform the same JUnit test with different input data.The simplest approach (but even the worst !) is duplicating the test code. 698 more words

Senza Categoria

Expected exceptions

Sometimes you want to verify that an exception is thrown in your code.

Let me show you three different ways to verify that the expected exception has been thrown. 659 more words


Spring Boot + JBehave example

We (developers at my organization) are bad at tests. The only thing we are worse at is documentation. So, the idea of “self-documenting” tests through JBehave seemed like a no-brainer. 327 more words


Requiring External Resources Before Attempting JUnit Tests

If you have an integration test that requires external resources to be available, like a local DynamoDB server, that test should be skipped rather than fail when the resources aren’t there. 100 more words