Open
Description
Describe the bug
I have enabled test fixures in my Android project, which is working.
However, when I try to create a class annotated with @Serializable
in the testFixtures
source set, the serializer doesn't seem to be available in my test:
kotlinx.serialization.SerializationException: Serializer for class 'MyClass' is not found.
Please ensure that class is marked as '@Serializable' and that the serialization compiler plugin is applied.
at kotlinx.serialization.internal.Platform_commonKt.serializerNotRegistered(Platform.common.kt:90)
at kotlinx.serialization.SerializersKt__SerializersKt.serializer(Serializers.kt:299)
at kotlinx.serialization.SerializersKt.serializer(Unknown Source)
at androidx.navigation.NavDestinationBuilder.<init>(NavDestinationBuilder.kt:91)
...
When I place the same class in the test
source set, the serializer is available in my test.
To Reproduce
# gradle.properties
android.experimental.enableTestFixtures=true
android.experimental.enableTestFixturesKotlinSupport=true
// project level build.gradle.kts
plugins {
alias(libs.plugins.kotlin.serialization)
}
dependencies {
testImplementation(libs.kotlinx.serialization.json)
testFixturesImplementation(libs.kotlinx.serialization.json)
}
Expected behavior
When I move the @Serializable
class from the test
source set to testFixtures
, the serializer is still available in my test.
Environment
- Kotlin version: 2.1.10
- Library version: 1.8.0
- Kotlin platforms: JVM
- Gradle version: 8.10.2
- IDE version: N/A