Kotlin Power Assert

Published: 07 June 2024
on channel: Pairing with Duncan
927
38

My regular viewer will know that I’m a test-driven fanatic. I love to find new ways to make tests more expressive and economic, so I was excited when I saw that there was a lightning talk at KotlinConf on Kotlin Power-assert (https://kotlinlang.org/docs/power-ass....

Power-assert is a compiler plugin that enhances the regular Kotlin assert function. It promises to help us understand why a test failed without needing complex assertion libraries. As a developer with a bit of a complex assertion library habit, this is intriguing, so please join me as I convert some tests from plain old JUnit and the Strikt assertion library to see if Power-Assert is testing methadone.

In this episode

00:00:56 Looking at ListStockTests
00:01:52 We should use Kotlin.test.assertEquals not Junit
00:03:05 What does an assertion failure look like?
00:03:58 Why do we have so many assertions?
00:06:10 What if every assertion was just assertTrue?
00:06:52 Enter Power-assert
00:08:06 assert now has super powers
00:12:08 Power-assert sees the whoe boolean expression argument to assert
00:13:15 Comparing Power-assert and Strikt
00:21:30 Soft assertions in Power-assert
00:24:50 Combining Power-assert and JUnit assertAll

I get lots of questions about the test progress bar. It was written by the inimitable @dmitrykandalov. To use it install his Liveplugin (https://plugins.jetbrains.com/plugin/...) and then this gist https://gist.github.com/dmcg/1f56ac39...

This video is one of lots on testing (   • Testing  ) and the code is from my Test Driven Gilded Rose project (   • Test Driven Gilded Rose in Kotlin  ) available on GitHub (https://github.com/dmcg/gilded-rose-tdd).

If you like this video, you’ll probably like my book Java to Kotlin, A Refactoring Guidebook (http://java-to-kotlin.dev). It's about far more than just the syntax differences between the languages - it shows how to upgrade your thinking to a more functional style.


Watch video Kotlin Power Assert online without registration, duration hours minute second in high quality. This video was added by user Pairing with Duncan 07 June 2024, don't forget to share it with your friends and acquaintances, it has been viewed on our site 927 once and liked it 38 people.