Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ apiValidation {
"spring-4x-kafka-tests",
"spring-4x-tests",
"spring-3x-tests",
"spring-2x-tests"
"spring-2x-tests",
"ktor-di-tests",
"ktor-koin-tests",
"ktor-test-fixtures",
)
}
kover {
Expand Down
50 changes: 37 additions & 13 deletions docs/Components/02-kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,28 +230,52 @@ messages.
When all the configuration is done, it is time to tell to application to use our `TestSystemInterceptor` and
configuration values.

#### TestSystemInterceptor and TestInitializer
#### TestSystemInterceptor and Bean Registration

Register the interceptor and serde using `addTestDependencies`:

**Spring Boot 2.x / 3.x:**

```kotlin
class TestInitializer : BaseApplicationContextInitializer({
bean<TestSystemInterceptor>(isPrimary = true)
bean { StoveSerde.jackson.anyByteArraySerde(yourObjectMapper()) } // or any serde that implements StoveSerde<Any, ByteArray>
})
import com.trendyol.stove.testing.e2e.addTestDependencies

fun SpringApplication.addTestDependencies() {
this.addInitializers(TestInitializer())
}
springBoot(
runner = { parameters ->
runApplication<MyApp>(*parameters) {
addTestDependencies {
bean<TestSystemInterceptor>(isPrimary = true)
bean { StoveSerde.jackson.anyByteArraySerde(yourObjectMapper()) }
}
}
},
```

#### Configuring the SystemUnderTest and Parameters
**Spring Boot 4.x:**

```kotlin
import com.trendyol.stove.testing.e2e.addTestDependencies4x

springBoot(
runner = { parameters ->
runApplication<MyApp>(*parameters) {
addTestDependencies4x {
registerBean<TestSystemInterceptor>(primary = true)
registerBean { StoveSerde.jackson.anyByteArraySerde(yourObjectMapper()) }
}
}
},
```

`addTestDependencies` is an extension that helps us to register our dependencies in the application.
#### Configuring the SystemUnderTest and Parameters

```kotlin hl_lines="4"
```kotlin hl_lines="4-8"
springBoot(
runner = { parameters ->
com.trendyol.exampleapp.run(parameters) {
addTestDependencies() // Enable TestInitializer with extensions call
runApplication<MyApp>(*parameters) {
addTestDependencies {
bean<TestSystemInterceptor>(isPrimary = true)
bean { StoveSerde.jackson.anyByteArraySerde(yourObjectMapper()) }
}
}
},
withParameters = listOf(
Expand Down
Loading
Loading