Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serializer not generated in test fixtures (testFixtures) #2932

Open
jonnyandrew opened this issue Feb 19, 2025 · 0 comments
Open

Serializer not generated in test fixtures (testFixtures) #2932

jonnyandrew opened this issue Feb 19, 2025 · 0 comments

Comments

@jonnyandrew
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant