January 2018
Intermediate to advanced
414 pages
10h 29m
English
Now, that we have Kluent, let's modify our tests. First, we will work on CustomerServiceTest.
We will modify our test for getting one valid customer, which was written as shown:
@Testfun `we should get a customer with a valid id`() { val customer = customerService.getCustomer(1) assertNotNull(customer) assertEquals(customer?.name, "Kotlin")}
We can change our assertNotNull assertion to use shouldNoteNull, a high-level function that we can use in an object:
package com.microservices.chapter09import junit.framework.Assert.assertEqualsimport org.amshove.kluent.shouldNotBeNullimport org.junit.Testimport org.junit.runner.RunWithimport org.springframework.beans.factory.annotation.Autowiredimport org.springframework.boot.test.context.SpringBootTest ...
Read now
Unlock full access