unit-test 4

Spock random order of tests - how to?

Spock Framework executes test methods (features) in a single class (specification) in the declaration order. There is nothing wrong in this default behavior - we should write tests with their isolation in mind. However, in some cases, we would like to randomize test methods execution. Today we are going to learn how to do it.

How to avoid "No tests were found" when using JUnit 5 with Groovy?

In this short blog post I would like to explain how to avoid popular mistake when you write your first JUnit 5 test case in Groovy.

Ratpack: register SessionModule in handler unit test

Unit testing Ratpack handlers has many benefits. In the previous post we have learned how to mock Session object to use it with GroovyRequestFixture. Today instead of mocking we will register SessionModule and then we will use a real session object.

Ratpack: mocking Session object in GroovyRequestFixture test

Ratpack allows you unit test handlers using GroovyRequestFixture class. The good thing about this approach is that it does not require running the whole application and you can quickly test if the handler does what you expect. However, if you retrieve objects from Raptack’s registry you will run into a problem - registry in this case is empty.