Annotation Type TestCaseInstanceProvider


  • @Documented
    @Retention(RUNTIME)
    @Target(TYPE)
    @Inherited
    public @interface TestCaseInstanceProvider
    Determines how instances of the test suite class are created for each test case. By default JUnit creates a new class instance for every test to prevent test case ordering dependencies. This is sometimes inconvenient as there is no "suite" context other than static fields (which are a nuisance to clean up properly, for example). This annotation changes the default behavior and permits the test cases to be executed on the same instance, for example. Note that special care should be given to scenarios in which same-instance is reused with arguments provided via ParametersFactory (each set of parameters will create a separate instance, which will then be used to run all of test suite's test cases). Note that the same instance will be used if the test cases are multiplied with Seeds or Repeat annotations.
    See Also:
    TestCaseInstanceProvider.Type.INSTANCE_PER_TEST_METHOD, TestCaseInstanceProvider.Type.INSTANCE_PER_CONSTRUCTOR_ARGS
    • Element Detail

      • value

        TestCaseInstanceProvider.Type value
        Default:
        com.carrotsearch.randomizedtesting.annotations.TestCaseInstanceProvider.Type.INSTANCE_PER_TEST_METHOD