Skip to content

Throw a meaningful exception if uiTestJUnit4 used with a wrong configuration #3517

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

Closed
igordmn opened this issue Aug 17, 2023 · 2 comments
Closed
Labels
enhancement New feature or request test

Comments

@igordmn
Copy link
Collaborator

igordmn commented Aug 17, 2023

It can be used without @rule or with Junit5 annotations. We should throw a meaningful in this case instead of kotlin.UninitializedPropertyAccessException: lateinit property scene has not been initialized.

See #1336 (comment).

@igordmn igordmn added enhancement New feature or request test labels Aug 17, 2023
@igordmn igordmn changed the title Throw a meaningful exception if compose.uiTestJUnit4 used with a wrong configuration Throw a meaningful exception if uiTestJUnit4 used with a wrong configuration Aug 17, 2023
@sunny-chung
Copy link

sunny-chung commented Jun 8, 2024

Hi, I have also encountered this error with GitHub Actions, but only with Intel macos-12 runners and not M1 macos-14 or other OSes.

kotlin.UninitializedPropertyAccessException: lateinit property scene has not been initialized
	at androidx.compose.ui.test.SkikoComposeUiTest.getScene(ComposeUiTest.skikoMain.kt:134)
	at androidx.compose.ui.test.SkikoComposeUiTest.withScene(ComposeUiTest.skikoMain.kt:158)
	at androidx.compose.ui.test.SkikoComposeUiTest.access$withScene(ComposeUiTest.skikoMain.kt:88)
	at androidx.compose.ui.test.SkikoComposeUiTest$runTest$1.invoke(ComposeUiTest.skikoMain.kt:145)
	at androidx.compose.ui.test.ComposeRootRegistry.withRegistry(ComposeRootRegistry.skiko.kt:83)
	at androidx.compose.ui.test.SkikoComposeUiTest.runTest(ComposeUiTest.skikoMain.kt:144)
	at androidx.compose.ui.test.ComposeUiTest_skikoMainKt.runComposeUiTest(ComposeUiTest.skikoMain.kt:59)
	at androidx.compose.ui.test.ComposeUiTest_skikoMainKt.runComposeUiTest$default(ComposeUiTest.skikoMain.kt:58)
	at com.sunnychung.application.multiplatform.hellohttp.test.RequestResponseTestUtilKt$runTest$1.invoke(RequestResponseTestUtil.kt:68)
	... 3 more

I have both JUnit 5 and JUnit 4 in the project, but in this particular module only JUnit 4 is in the classpath. Only JUnit 4 annotations (org.junit.Test and not org.junit.jupiter.api.Test) are used. I am using a custom test rule that is not related to Compose. I have @RunWith(Parameterized::class) annotated with the test class. There is also a custom static function marked with @BeforeClass.

Any workaround is available?

Edit: It does not happen consistently, and did happen to Windows runner as well. When it happens, all the subsequent runComposeUiTest test cases fail.

@okushnikov
Copy link
Collaborator

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

@JetBrains JetBrains locked and limited conversation to collaborators Dec 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request test
Projects
None yet
Development

No branches or pull requests

3 participants