Barys Ilyushonak aka Boris Lead Software Engineer @ Foundation Services / München [Java => Erlang => Scala]

```scala /** * graph-based analysis * 24x7 SaaS application * 0-downtime deployment * real-time processing * root-cause analysis */ val techStack = Map( "lang" -> "scala", "effect" -> "cats-effect", "web" -> "http4s", "messaging" -> "kafka", "frontEnd" -> "nginx", "storage" -> "MongoDB", "os" -> "debian", "orchestration" -> "k8s" ) ```

What do you test?

* Happy path * Corner cases * Error handling * Performance * Others...

=> example-based testing

Example #1

Example #2

"JSON is not the harmless, general purpose data-interchange format as many do believe. No two parsers behave the same way!"
(c) Nicolas Seriot, "Parsing JSON is a Minefield"

How-to test unknown?

**Property-based testing** helps you to **find edge cases** and **understand code behaviour** We saw **patterns** you could use to verify your algebra Property-based testing is **popular**, e.g. `cats-laws` module from Typelevel > ScalaCheck is used by several prominent Scala projects, for example the Scala compiler and the Akka concurrency framework. (www.scalacheck.org)

References

Scott Wlaschin [An introduction to property based testing](https://fsharpforfunandprofit.com/pbt/) FRED HÉBERT: [EVERYTHING IS TERRIBLE](http://s3.amazonaws.com/erlang-conferences-production/media/files/000/000/766/original/Fred_Herbert_-_Everything_is_terrible.pdf?1510584735) Charles O'Farrell ["How I learned to stop unit testing and love property-based testing"](http://blog.charleso.org/property-testing-preso/#1) Chris Phelps [Cats Law Checking with Discipline](http://chrisphelps.github.io/scala/2016/11/30/Cats-Law-Checking-With-Discipline/) ScalaCheck: [The Definitive Guide](https://booksites.artima.com/scalacheck/examples/html/ch06.html) John Hughes [Testing the Hard Stuff and Staying Sane](https://www.infoq.com/presentations/testing-techniques-case-study) RTFM: * https://www.scalacheck.org/ * http://www.scalatest.org/user_guide/property_based_testing

Where is the code?

[Take a look at full presentation](https://biscout24.github.io/ltk-props-testing/) Code examples at [git@github.com:biscout24/ltk-props-testing.git](https://github.com/biscout24/ltk-props-testing/)

Let's write some tests together!