Closed fpitpit closed 2 weeks ago
in kotlin multiplatform all android all tests passed but it said ` Task :composeApp:testDebugUnitTest FAILED FAILURE: Build failed with an exception.
` when I launch gradlew composeApp:testDebugUnitTest or testReleaseUnitTest.
This is my actual class for android :
`
@ExtendWith(RobolectricExtension::class) @Config( application = WhoIsApplication::class, sdk = [Config.OLDEST_SDK, Build.VERSION_CODES.UPSIDE_DOWN_CAKE]) @Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING") actual abstract class UsingContext actual constructor() { init { println("test is executed on ${buildPlatform().name}") }
@BeforeTest
open fun setUp() {
ShadowLog.stream = System.out
}
@OptIn(ExperimentalResourceApi::class)
@Composable
actual fun initPreviewContextConfiguration() {
CompositionLocalProvider(LocalInspectionMode provides true) {
PreviewContextConfigurationEffect()
}
}
}
`
`
Caused by: org.junit.runners.model.InvalidTestClassError: Invalid test class '.........UsingContext':
`
ok the plugin believes that my actual class is a Test so it failed (Gradle Test Executor 1)
To fix it I must exclude my actual class in test block in my gradle file :
tasks.withType<Test>().configureEach { useJUnitPlatform() exclude("**/UsingContext.class") }
Why your UsingContext
class is annotated with @ExtendWith(RobolectricExtension::class)
if it is not a test class?
Probably that causing the issue.
I'm seeing this too, but with a pure-Android project. It seems like version 0.8.0
of the Gradle plugin exists on the Gradle Plugin Portal, however the extension itself has no such version available on Maven Central. Is the extension deployed to a different repository with the latest version, or did something in the deployment go awry?
Apologies for the confusion. I mistakenly only closed the release on OSS. Could you please check again? Sorry for the inconvenience. https://repo1.maven.org/maven2/tech/apter/junit5/jupiter/robolectric-extension/0.8.0/
@fpitpit Could you confirm this is solved your issue? Am I close this issue?
I can confirm that resolving version 0.8.0 of the plugin now also fetches the extension without issue. Thank you for checking this!
Yes good job. But I see that reports testDebugUnitTest and testReleaseUnitTest not included in all tests report. I've must go in reports/tests/testDebugUnitTest to see them.
And with junit4 I saw result by API android but not with your plugin. I put config robolectric with API 24 and API 34
@fpitpit Thank you for your confirmation. Please open a separate issue about the test report, and attach a test project where the issue can be reproduced.
In a Kotlin mutliplatform I try to add plugin for android module using version catalog but build failed to resolve the plugin
version catalog :
build.gradle.kts (root project)
build.gradle.kts (composeApp/android)
I've got error :
Failed to resolve: tech.apter.junit5.jupiter:robolectric-extension:0.8.0
I've same error on a classic project android
all tests failed now on kotlin multiplatform : if I reuse junit4 and run with robolectric test runner it works but not with your plugin