Configuring a test class to use custom configuration

To do this, open the Spring application's test class and use an @ContextConfiguration annotation to specify the configuration classes to be used by the test class. Open PlaceReviewerApplicationTests.kt (located in the com.example.placereviewer package of your project's src/test/kotlin directory). Now, set its configuration class as follows:

package com.example.placereviewerimport com.example.placereviewer.config.TestConfigimport org.junit.runner.RunWithimport org.springframework.boot.test.context.SpringBootTestimport org.springframework.test.context.ContextConfigurationimport org.springframework.test.context.junit4.SpringRunner@RunWith(SpringRunner::class)@SpringBootTest@ContextConfiguration(classes ...

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.