From the course: Build Spring Boot Apps with the Kotlin Programming Language

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

The Kotlin test assertions

The Kotlin test assertions

- So assertEquals comes from the kotlin.test package and I've got the documentation of this package on the screen right now. And if we scroll down and look at the function we'll see that as well as the usual ones you might expect like assertEquals, there are actually some others here that are actually quite nice. Ones I want to point out are assertSame and assertNotSame. That checks reference equality, instead of value equality but I want to point out that always check the documentation before you use some of these. So, for example, there is one down here called last, uh, let's get this one, shouldbe, but if you go to the details of that it will say, here is a warning here, this is an experimental part of the API and it may be changed or removed in newer releases. So do check the documentation but certainly the ones we might expect to use like assertTrue, assertNull, assertequals they're all there and all usable in the way you'd normally expect. So let's put in another test method…

Contents