Writing your first test

Writing code for application tests is like writing code for any other part of a Spring application. You can make use of components and services as you would in any other part of your application. Let us demonstrate this, shall we?

Add the following TestUserService interface to com.example.placereviewer.service:

package com.example.placereviewer.serviceimport com.example.placereviewer.data.model.Userinterface TestUserService {  fun getUser(): User}

Now, add the following TestUserServiceImpl class to the package:

package com.example.placereviewer.serviceimport com.example.placereviewer.data.model.Userimport org.springframework.stereotype.Service@Serviceinternal class TestUserServiceImpl : TestUserService {  //Test stub ...

Get Kotlin Programming By Example 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.