Saturday, February 13, 2021
Don’t ask what you can do for your testing library, ask what it can do for you! So what can it do? It turns out that much more than displaying a nice green and red report. What if we make the library generate the test data? And while we’re at it, maybe it could also think of the edge cases for which our code is wrong? Oh, and when it finds them, it should simplify them a bit before returning to us, so that we can quickly identify the root cause of the problem. And repeat that a thousand times, just to be sure. Sounds good? That’s exactly what property-based testing has to offer. I’ll show how to get started with this kind of testing in Scala, using using ScalaTest and ScalaCheck. But isn’t it all too good to be true, surely there’s some fine print? Of course there is. I’ll cover that as well.
Curious to know how good your tests are? There’s an easy way to find out: use mutation testing!
Most of us use code coverage to measure how effective our tests are. But what does code coverage really mean? How many times have you seen a test with a missing assertion or even assertions in comments? This is where mutation testing will help you. A mutation testing framework inserts small bugs into your code, hoping that your tests can spot them.
In this talk, you will learn the basics of mutation testing, and how you can use it in your Scala projects with Stryker4s, the mutation testing framework for Scala.
MUnit is a testing library for Scala built. “Another one?!”, you may say? In this talk we’ll explore together the most notable features of MUnit and see what makes this little library unique! Via a series of live code examples, we’ll answers questions like: - Why does MUnit not have a DSL? - How do we integrate MUnit with other libraries? - How can MUnit help dealing with flaky tests?
At the end the presentation, MUnit may become your new favorite testing library!