Module to configure Alkemy using Spring configuration properties
Gradle:
// build.gradle
testImplementation "io.resoluteworks:alkemy-spring:${alkemyVersion}"
Autowire AlkemyProperties
in the constructor together with other Spring beans, then use it to register the
AlkemyExtension
, e.g.
class MySpec(alkemyProperties: AlkemyProperties, service: UserService) : WordSpec({
val alkemyContext = alkemyContext(alkemyProperties)
Configure Alkemy using Spring configuration properties, e.g.
# src/test/resources/application.yml
alkemy:
base-url: https://the-internet.herokuapp.com
headless: true
To configure Alkemy dynamically, use AlkemyProperties
' copy constructor to overwrite any properties.
For example, to configure alkemy.base-url
with the webserver port that was randomly assigned by Spring Boot Test:
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
class DynamicConfigurationTest(alkemyProperties: AlkemyProperties, @LocalServerPort serverPort: Int) : WordSpec() {
init {
val alkemyContext = alkemyContext(
alkemyProperties.copy(
baseUrl = "http://localhost:${serverPort}",
)
)
If Kotest auto scan is disabled, you will need
to manually load the AlkemyWebDriverPoolExtension
and SpringAutowireConstructorExtension
extension in your Project
config, e.g.
class ProjectConfig : AbstractProjectConfig() {
override fun extensions() = listOf(AlkemyWebDriverPoolExtension, SpringAutowireConstructorExtension)
}