import junit.framework.TestSuite; import junit.framework.TestCase; public class MyTestSuite extends TestSuite { public static TestSuite suite() { TestSuite suite = new TestSuite(); suite.addTest(new TestCaseExample("testMethod")); suite.setName("My Test Suite"); return suite; } }
import junit.framework.TestSuite; import junit.framework.TestCase; public class MyTestRunner { public static void main(String[] args) { String testName = "My Dynamic Test Suite Name"; TestSuite suite = new TestSuite(); suite.addTest(new TestCaseExample("testMethod")); suite.setName(testName); junit.textui.TestRunner.run(suite); } }In this example, we create a TestSuite object and add a test method called "testMethod" from the TestCaseExample class. We then set the name of the suite to a variable called "testName", which can be dynamically set based on the requirements. Finally, we run the suite using the TestRunner class provided by JUnit. This class is included in the junit.framework package library.