Part 2: Talks Spaces Summit v2.0

On 15-08-2018
Category: Blog, Development

Last June, Spaces Summit was organized by and for bol.com employees. At Techlab, we want to celebrate this event by highlighting two presentations every month. This month, we will look at two exciting presentations about aptly-named testing frameworks: Spock, and Karate.

Talk #1: Test long and prosper

Speaker: Cas Plattel

Genre: Frontend, Backend

Slides

Ever found cucumber tests requiring too much boilerplate and JUnit tests a bit too low level? Spock is a testing and specification framework for applications. It has an expressive syntax to write your tests in and can be used to unit test, integration test or even test your frontend using an additional layer called Geb.

For a long time, we’ve been using Cucumber as our testing framework for component and integration tests. As our code base tended to grow, so did the complexity behind our Cucumber tests. Writing step definitions became quite cumbersome. It also easily introduced shared state between tests, due to reusing of sentences in the gherkin (feature) files. Cucumber allowed us to test by a specification, which we liked, as well as clearly define the business rules of our code. However, the downsides became too big to keep using it.

In addition to Cucumber, we extensively used JUnit to unit test our code, which worked okay but easily trapped us into writing very technical driven tests. There was no easy way to define the behavior you were trying to test other than writing comments around your tests which was far from ideal. We also tend to run parameterized tests, which is very clunky in JUnit.

Hence our test setup could do with an improvement; we started using Spock as an experiment. New stories we picked up would be tested using this new testing framework. Ever since the switch, we’ve never looked back at the alternatives. Spock allowed us to still describe high-level flows (the behavior) while keeping the code low level, similar to JUnit. Mocking in Spock is very easy, as well as parameterizing your tests.

Are there any downsides to Spock? Of course. Our main concern was that you write your Spock tests in Groovy, which means goodbye to type safety, something we really liked. Also, argument capturing in your verification step can be somewhat clunky compared to other testing frameworks.

All in all, Spock is worth a shot if you’re not satisfied with your current test setup. Test long and prosper!

Talk #2: Wax on, wax off

Speaker: Carla de Groot

Genre: Backend

Slides

Are you looking for the best framework fit for API testing? Look no further. I already did this for you.

As your sensei, I’ll give you a solid base for your first kata in Karate so you can further master the art of API testing.

There is also a meetup coming up inculding the last talk as well. You can still join!