Package 

Class AndroidComposeExtensionKt

    • Constructor Detail

    • Method Detail

      • createComposeExtension

         final static ComposeExtension createComposeExtension()

        Factory method to provide a JUnit 5 extension for Compose using its RegisterExtension API for field injection. Prefer this over createAndroidComposeExtension if you don't care about the specific activity class to use under the hood.

        class MyTests {
          @JvmField
          @RegisterExtension
          val extension = createComposeExtension()
        }
      • createAndroidComposeExtension

         final static <A extends ComponentActivity> AndroidComposeExtension<A> createAndroidComposeExtension()

        Factory method to provide a JUnit 5 extension for Compose using its RegisterExtension API for field injection. Prefer this over createComposeExtension if your tests require a custom Activity. This is usually the case for tests where the Compose content is set by that Activity, instead of via ComposeContext.setContent, provided through the extension. Make sure that you add the provided Activity to your app's manifest file.

      • createAndroidComposeExtension

         final static <A extends ComponentActivity> AndroidComposeExtension<A> createAndroidComposeExtension(Function0<ActivityScenario<A>> scenarioSupplier)

        Factory method to provide a JUnit 5 extension for Compose using its RegisterExtension API for field injection. Prefer this over createComposeExtension if your tests require a custom Activity. This is usually the case for tests where the Compose content is set by that Activity, instead of via ComposeContext.setContent, provided through the extension. Make sure that you add the provided Activity to your app's manifest file. This variant allows you to provide a custom ActivityScenario which is useful in cases where you may want to launch an activity with a custom intent, for example.

      • createAndroidComposeExtension

         final static <A extends ComponentActivity> AndroidComposeExtension<A> createAndroidComposeExtension(Class<A> activityClass, Function0<ActivityScenario<A>> scenarioSupplier)

        Factory method to provide a JUnit 5 extension for Compose using its RegisterExtension API for field injection. Prefer this over createComposeExtension if your tests require a custom Activity. This is usually the case for tests where the Compose content is set by that Activity, instead of via ComposeContext.setContent, provided through the extension. Make sure that you add the provided Activity to your app's manifest file. You may also provide an optional ActivityScenario supplier which is useful in cases where you may want to launch an activity with a custom intent,for example.