Testing Spring REST applications

In this section, we will continue towards test implementation and will be testing Spring-specific topics. First of all, we will specify the SprintRunner class, which is going to be used as the test runner for our tests:

package com.journaler 
 
import org.junit.After 
import org.junit.Before 
import org.junit.Test 
import org.junit.runner.RunWith 
import org.springframework.test.context.junit4.SpringRunner 
 
@RunWith(SpringRunner::class) 
class NoteTest { 
    ... 
} 

By annotating @RunWith(SpringRunner::class), we specified that SpringRunner will be used for test running and will be initializing TestContextManager to provide Spring testing functionality to standard tests. Let's run the test once more. Observe the output ...

Get Building Applications with Spring 5 and Kotlin now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.