0

Problem with kotlinx.serialization and running test in androidTest.

Lib version:

org.jetbrains.kotlinx:kotlinx-serialization-json:1.0.1
org.jetbrains.kotlin:kotlin-stdlib:1.4.10

My instance of Json:

Json(Json.Default) {
    serializersModule = SerializersModule {
        // serializers here
    }
    coerceInputValues = true
    ignoreUnknownKeys = true
    isLenient = true
}

UI test scheme

stub json -> json deserialise with kotlinx.serialization.json -> show screen

If I run UI test in androidTest folder, I will get exception

java.lang.ClassCastException: kotlinx.serialization.json.Json$Default cannot be cast to kotlinx.serialization.json.Json

Do you have any idea on how to solve this problem?

UPD

Another variant. Use without default

Json {
    serializersModule = SerializersModule {
        // serializers here
    }
    coerceInputValues = true
    ignoreUnknownKeys = true
    isLenient = true
}

Exception

No static method Json$default(Lkotlinx/serialization/json/Json;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lkotlinx/serialization/json/Json
KolinLoures
  • 130
  • 2
  • 10

1 Answers1

0

Problem was with allure framework

  1. issue here https://github.com/allure-framework/allure-kotlin/issues/38
  2. fix here https://github.com/allure-framework/allure-kotlin/pull/37
KolinLoures
  • 130
  • 2
  • 10