-
Notifications
You must be signed in to change notification settings - Fork 64
Assertions
Markus Amshove edited this page Feb 19, 2016
·
1 revision
This file contains examples on supported assertions.
JUnit:
assertEquals("hello", "hello");
Kluent:
"hello" shouldEqual "hello"
JUnit:
assertNotEquals("hello", "world");
Kluent:
"hello" shouldNotEqual "world"
JUnit:
assertSame(firstObject, secondObject);
Kluent:
firstObject shouldBe secondObject
JUnit:
assertNotSame(firstObject, secondObject);
Kluent:
firstObject shouldNotBe secondObject
JUnit:
assertArrayEquals(firstArray, secondArray);
Kluent:
firstArray shouldEqual secondArray
Kluent:
firstIterable shouldEqual secondIterable
val alice = Person("Alice", "Bob")
val jon = Person("Jon", "Doe")
val list = listOf(alice, jon)
list shouldContain jon
val alice = Person("Alice", "Bob")
val jon = Person("Jon", "Doe")
val list = listOf(alice, jon)
list shouldNotContain alice
val func = { throw IndexOutOfBoundsException() }
func shouldThrow IndexOutOfBoundsException::class
val func = { throw Exception("Hello World!") }
func shouldThrowTheException Exception::class withMessage "Hello World!"
val func = { throw Exception("Hello World!") }
func shouldThrow AnyException
val func = { throw Exception("Hello World!") }
func shouldNotThrow IndexOutOfBoundsException::class
val func = { throw Exception("Hello World!") }
func shouldNotThrowTheException IndexOutOfBoundsException::class withMessage "Nothing here"
val func = { Unit }
func shouldNotThrow AnyException