Kotools Assert
Kotools Assert is a lightweight assertions library for Kotlin.
1 assertEquals 1 1.assertEquals(1, "1 should equal 1") 1.assertEquals(1) { "$this should be equal to $it" } 2 assertNotEquals 0 2.assertNotEquals(0, "2 shouldn't be equal to 0") 2.assertNotEquals(0) { "$this shouldn't be equal to $it" } assertNull { null } assertNull("result should be null") { null } null.assertNull() null assertNull "result should be null" null assertNull { "result should be null" } assertNotNull { 3 } assertNotNull("result shouldn't be null") { 3 } 3.assertNotNull() 3 assertNotNull "result shouldn't be null" 3 assertNotNull { "result shouldn't be null" } assertFails { throw Exception() } assertFails<RuntimeException> { throw RuntimeException() } assertFails("Should fail") { throw Exception() } assertFails<RuntimeException>("Should fail with RuntimeException") { throw RuntimeException() }
Installation
Gradle
Kotlin DSL
testImplementation("io.github.kotools:assert:1.1.0")
Groovy DSL
testImplementation 'io.github.kotools:assert:1.1.0'
Maven
<dependency>
<groupId>io.github.kotoolsgroupId>
<artifactId>assertartifactId>
<version>1.1.0version>
<scope>testscope>
dependency>
Documentation
Latest documentation of Kotools Assert is available here.
Contributing
Feel free to contribute to the project with issues and pull requests.
License
This project is licensed under the MIT License.