Colleagues, welcome. It took to develop autotests android applications, docked Robolectric. Please explain popularly: what is the meaning of the constant in the @Config annotation? Thank!

    1 answer 1

    With its help, you can quickly and easily disrupt the config (oddly enough) of your test. For example:

    @RunWith(RobolectricGradleTestRunner.class) @Config(constants = BuildConfig.class, sdk = Build.VERSION_CODES.LOLLIPOP, manifest = "app/src/main/") public class MainActivityTest { ... } 

    constants required and contains the constants of your application, such as the build type (debug, relise), version, application package ("ru.whalemare.myapp" for example), etc.

    sdk optional and indicates which version of Android will need to be emulated. Those. in which environment the tests will be run.

    manifest also optional and necessary, if for example, for tests you need some special permissions. So I for example treated an error with library UiAutomator

     <uses-sdk tools:overrideLibrary="android.support.test.uiautomator.v18"/>