How can I add an instance of test case into junit4 test suite without annotation/class

StackOverflow https://stackoverflow.com/questions/22135694

  •  19-10-2022
  •  | 
  •  

سؤال

I have some test casees declared following JUnit4 annotation @Test like below:

public class SampleTest {
    @Test
    public void execute() {
    }
}

And I define a test suite declared like below:

public class FacadeMockTestSuite extends TestSuite {
    public static Test suite() {
        TestSuite suite = new TestSuite("My Test");
        // ...
        return suite;
    }
}

When I tried to add my test case into the suite, I found I can only use the class of the case, through either @SuiteClass or suite.addTest(new JUnit4TestAdapter(myTestClass));

But how can I directly insert a test case instance created by myself into the suite? Since I need to scan test case classes in my runtime and create them with non-default constructor?

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top