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.placereviewer

import com.example.placereviewer.config.TestConfig
import org.junit.runner.RunWith
import org.springframework.boot.test.context.SpringBootTest
import org.springframework.test.context.ContextConfiguration
import org.springframework.test.context.junit4.SpringRunner

@RunWith(SpringRunner::class)
@SpringBootTest
@ContextConfiguration(classes = [TestConfig::class])
class PlaceReviewerApplicationTests

Great work! You are now ready to write some application tests.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.79.65