Class BackgroundTestRule

  • All Implemented Interfaces:
    org.junit.rules.TestRule

    public final class BackgroundTestRule
    extends Object
    implements org.junit.rules.TestRule
    Let tests to run on background thread, if it has annotation BackgroundTestRule.BackgroundTest.

    This is useful for testing logic that explicitly forbids being called on the main thread.

    Example usage:

    {@code
    • Constructor Detail

      • BackgroundTestRule

        public BackgroundTestRule()
    • Method Detail

      • apply

        public org.junit.runners.model.Statement apply​(org.junit.runners.model.Statement base,
                                                       org.junit.runner.Description description)
        Specified by:
        apply in interface org.junit.rules.TestRule