Package 

Object TestableAndroidInjection


  • 
    public class TestableAndroidInjection
    
                        

    AndroidInjection wrapper that allows customizing dependency injection of Activity or Fragment.

    Important: Methods and properties of this object should be used only for testing purposes.

    • Method Detail

      • inject

         final Unit inject(Activity activity)

        Wrap AndroidInjection.inject method with helpful utilities for better testability of Activity class.

        Use] onActivityInject to customize behavior of this method in tests.

      • inject

         final Unit inject(Fragment fragment)

        Wrap AndroidInjection.inject method with helpful utilities for better testability of Fragment class.

        Use onFragmentInject to customize behavior of this method in tests.

      • getOnActivityInject

         final Function1<Activity, Unit> getOnActivityInject()

        Callback invoked when Activity class is being injected. It should be used in tests for manual dependency injection of Activity class.

        The most common use case is to replace ViewModelCreator.viewModelFactory with the factory that provides a view model with mocked use cases

      • setOnActivityInject

         final Unit setOnActivityInject(Function1<Activity, Unit> onActivityInject)

        Callback invoked when Activity class is being injected. It should be used in tests for manual dependency injection of Activity class.

        The most common use case is to replace ViewModelCreator.viewModelFactory with the factory that provides a view model with mocked use cases

      • getOnFragmentInject

         final Function1<Fragment, Unit> getOnFragmentInject()

        Callback invoked when Fragment class is being injected. It should be used in tests for manual dependency injection of Fragment class.

        The most common use case is to replace ViewModelCreator.viewModelFactory with the factory that provides a view model with mocked use cases

      • setOnFragmentInject

         final Unit setOnFragmentInject(Function1<Fragment, Unit> onFragmentInject)

        Callback invoked when Fragment class is being injected. It should be used in tests for manual dependency injection of Fragment class.

        The most common use case is to replace ViewModelCreator.viewModelFactory with the factory that provides a view model with mocked use cases