junit.framework
Class TestSuite
- Test
A
TestSuite is a
Composite of Tests.
It runs a collection of test cases. Here is an example using
the dynamic test definition.
TestSuite suite= new TestSuite();
suite.addTest(new MathTest("testAdd"));
suite.addTest(new MathTest("testDivideByZero"));
Alternatively, a TestSuite can extract the tests to be run automatically.
To do so you pass the class of your TestCase class to the
TestSuite constructor.
TestSuite suite= new TestSuite(MathTest.class);
This constructor creates a suite with all the methods
starting with "test" that take no arguments.
A final option is to do the same for a large array of test classes.
Class[] testClasses = { MathTest.class, AnotherTest.class }
TestSuite suite= new TestSuite(testClasses);
TestSuite()- Constructs an empty TestSuite.
|
TestSuite(Class>... classes)- Constructs a TestSuite from the given array of classes.
|
TestSuite(TestCase> theClass)- Constructs a TestSuite from the given class.
|
TestSuite(TestCase> theClass, String name)- Constructs a TestSuite from the given class with the given name.
|
TestSuite(TestCase>[] classes, String name)- Constructs a TestSuite from the given array of classes with the given name.
|
TestSuite(String name)- Constructs an empty TestSuite.
|
@Override | String toString()
|
void | addTest(Test test)- Adds a test to the suite.
|
void | addTestSuite(TestCase> testClass)- Adds the tests from the given class to the suite
|
int | countTestCases()- Counts the number of test cases that will be run by this test.
|
static Test | createTest(TestCase> theClass, String name)- ...as the moon sets over the early morning Merlin, Oregon
mountains, our intrepid adventurers type...
|
static Constructor | extends TestCase> getTestConstructor(TestCase> theClass)- Gets a constructor which takes a single String as
its argument or a no arg constructor.
|
String | getName()- Returns the name of the suite.
|
void | run(TestResult result)- Runs the tests and collects their result in a TestResult.
|
void | runTest(Test test, TestResult result)
|
void | setName(String name)- Sets the name of the suite.
|
Test | testAt(int index)- Returns the test at the given index
|
int | testCount()- Returns the number of tests in this suite
|
Enumeration | tests()- Returns the tests as an enumeration
|
static Test | warning(String message)- Returns a test which will fail and log a warning message.
|
clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait |
TestSuite
public TestSuite()
Constructs an empty TestSuite.
View More Examples of TestSuite()
1: public static Test suite() {
2: TestSuite suite = new TestSuite();
3: suite.addTestSuite(JBossMysqldDynamicMBeanTest.class);
4: return suite;
5: }
View Full Code Here
1: {
2: TestSuite suite = new TestSuite();
3: suite.addTestSuite( DataPointTest.class );
4: suite.addTestSuite( MetricTest.class );
5: return suite;
View Full Code Here
1: static public Test suite() {
2: TestSuite suite = new TestSuite();
3: suite.addTestSuite(SimpleTest.class);
4: suite.addTestSuite(LessSimpleTest.class);
5: return suite;
View Full Code Here
TestSuite
public TestSuite(Class>... classes)
Constructs a TestSuite from the given array of classes.
View More Examples of TestSuite(Class>... classes)
1: public static Test suite() {
2: TestSuite anSuite = new TestSuite("Activity");
3: anSuite.addTest(TestActivityBuilder.suite());
4: return anSuite;
5: }
View Full Code Here
1: public static TestSuite suite() {
2: TestSuite anSuite = new TestSuite("All");
3:
4: anSuite.addTest(TestAllUtil.suite());
5: anSuite.addTest(TestAllSeSAmMain.suite());
View Full Code Here
1: }
2: TestSuite suite = new TestSuite("BaseSuite");
3: suite.addTest(org.mmbase.module.core.CoreSuite.suite());
4: suite.addTest(org.mmbase.storage.search.implementation.ImplementationSuite.suite());
5: suite.addTest(org.mmbase.storage.search.legacy.LegacySuite.suite());
View Full Code Here
1:
2: suite = new TestSuite("AllTests");
3: suite.addTestSuite(ASNParserTest.class);
4: suite.addTestSuite(MainTest.class);
View Full Code Here
TestSuite
public TestSuite(TestCase> theClass)
Constructs a TestSuite from the given class. Adds all the methods
starting with "test" as test cases to the suite.
Parts of this method were written at 2337 meters in the Hueffihuette,
Kanton Uri
View More Examples of TestSuite(TestCase> theClass)
1: public static Test suite() {
2: TestSuite anSuite = new TestSuite("Activity");
3: anSuite.addTest(TestActivityBuilder.suite());
4: return anSuite;
5: }
View Full Code Here
1: public static TestSuite suite() {
2: TestSuite anSuite = new TestSuite("All");
3:
4: anSuite.addTest(TestAllUtil.suite());
5: anSuite.addTest(TestAllSeSAmMain.suite());
View Full Code Here
1: }
2: TestSuite suite = new TestSuite("BaseSuite");
3: suite.addTest(org.mmbase.module.core.CoreSuite.suite());
4: suite.addTest(org.mmbase.storage.search.implementation.ImplementationSuite.suite());
5: suite.addTest(org.mmbase.storage.search.legacy.LegacySuite.suite());
View Full Code Here
1:
2: suite = new TestSuite("AllTests");
3: suite.addTestSuite(ASNParserTest.class);
4: suite.addTestSuite(MainTest.class);
View Full Code Here
TestSuite
public TestSuite(TestCase> theClass,
String name) Constructs a TestSuite from the given class with the given name.
TestSuite.TestSuite(Class)
View More Examples of TestSuite(TestCase> theClass,String name)
1: System.out.println("Testing Database access !");
2: return new TestSuite(DbTest.class, "DbTest");
3: }
4: protected void setUp()
5: {
View Full Code Here
1: System.out.println("Testing ToolBox !");
2: return new TestSuite(ToolBoxTest.class, "ToolBoxTest");
3: }
4: public static Test findTest(TestSuite list, String name)
5: {
View Full Code Here
TestSuite
public TestSuite(TestCase>[] classes,
String name) Constructs a TestSuite from the given array of classes with the given name.
TestSuite.TestSuite(Class[])
View More Examples of TestSuite(TestCase>[] classes,String name)
1: System.out.println("Testing Database access !");
2: return new TestSuite(DbTest.class, "DbTest");
3: }
4: protected void setUp()
5: {
View Full Code Here
1: System.out.println("Testing ToolBox !");
2: return new TestSuite(ToolBoxTest.class, "ToolBoxTest");
3: }
4: public static Test findTest(TestSuite list, String name)
5: {
View Full Code Here
View More Examples of TestSuite(String name)
1: public static Test suite() {
2: TestSuite anSuite = new TestSuite("Activity");
3: anSuite.addTest(TestActivityBuilder.suite());
4: return anSuite;
5: }
View Full Code Here
1: public static TestSuite suite() {
2: TestSuite anSuite = new TestSuite("All");
3:
4: anSuite.addTest(TestAllUtil.suite());
5: anSuite.addTest(TestAllSeSAmMain.suite());
View Full Code Here
1: }
2: TestSuite suite = new TestSuite("BaseSuite");
3: suite.addTest(org.mmbase.module.core.CoreSuite.suite());
4: suite.addTest(org.mmbase.storage.search.implementation.ImplementationSuite.suite());
5: suite.addTest(org.mmbase.storage.search.legacy.LegacySuite.suite());
View Full Code Here
1:
2: suite = new TestSuite("AllTests");
3: suite.addTestSuite(ASNParserTest.class);
4: suite.addTestSuite(MainTest.class);
View Full Code Here
addTest
public void addTest(Test test)
Adds a test to the suite.
View More Examples of addTest(Test test)
1: import ;
2: import ;
3:
4: ...
5: public static Test suite(String classTitle, String path, Pattern[] includes, Pattern[] excludes) {
6: TestSuite suite = new TestSuite("Test for " + classTitle);
7: List<String> classnames = ClassFinder.getClasses(
8: ...
9: Method method = type.getDeclaredMethod("suite", new Class[] {});
10: suite.addTest((Test) method.invoke(type, new Object[] {}));
11: } catch (Exception e) {
View Full Code Here
1: import ;
2: import ;
3: import ;
4: ...
5: public static void main(String[] args) {
6: TestSuite ts = new TestSuite();
7: for( int i=0; i<args.length; i++ )
8: ...
9: if( o instanceof Test )
10: ts.addTest( (Test)o );
11: } catch( Exception e ) {
View Full Code Here
1: public static Test suite() {
2: TestSuite suite= new TestSuite();
3: ...
4: suite.addTest(AAssociateRQTest.suite());
5: ...
6: suite.addTest(AAssociateACTest.suite());
7: ...
8: suite.addTest(AAssociateRJTest.suite());
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: public static Test suite() {
6: TestSuite suite = new TestSuite();
7:
8: ...
9: suite.addTest(BootStrapperTest.suite());
10:
11: ...
12: if (Modifier.isStatic(suiteMethod.getModifiers())) {
13: suite.addTest((Test) suiteMethod.invoke(null, null));
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: public static Test suite() {
6: TestSuite suite = new TestSuite();
7:
8: ...
9: suite.addTest(BootStrapperTest.suite());
10:
11: ...
12: if (Modifier.isStatic(suiteMethod.getModifiers())) {
13: suite.addTest((Test) suiteMethod.invoke(null, null));
View Full Code Here
addTestSuite
public void addTestSuite(TestCase> testClass)
Adds the tests from the given class to the suite
View More Examples of addTestSuite(TestCase> testClass)
1: import ;
2: import ;
3:
4: ...
5: public static Test suite() {
6: TestSuite suite = new TestSuite(
7: "Test for org.rrexky.security.crypto.jcef.providers.sunjce.tests.blocksymmetricprotection");
8: ...
9: suite.addTestSuite(RC2BlockSymmetricProtection_SunJCETest.class);
10: ...
11: suite.addTestSuite(AES224BlockSymmetricProtection_SunJCETest.class);
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: public static Test suite() {
6: TestSuite suite = new TestSuite(
7: "Test for org.rrexky.security.crypto.jcef.providers.iaik.tests.blocksymmetricprotection");
8: ...
9: suite.addTestSuite(BlowfishBlockSymmetricProtection_IAIKTest.class);
10: ...
11: suite.addTestSuite(TripleDESBlockSymmetricProtection_IAIKTest.class);
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: final File jobDir, final File htdocs, final List selftests) {
6: TestSuite suite =
7: ...
8: new TestSuite("Test(s) for org.archive.crawler.selftest");
9: for (Iterator i = selftests.iterator(); i.hasNext();) {
10: ...
11: suite.addTestSuite((Class)i.next());
View Full Code Here
View More Examples of countTestCases()
1: import ;
2: import ;
3: import ;
4: ...
5: }
6: else if (test instanceof TestSuite) {
7: ...
8: TestSuite testSuite = (TestSuite) test;
9: bulletinBoard.println(
10: ...
11: + formatTestCount(
12: testSuite.countTestCases()));
View Full Code Here
1:
2: import ;
3: import ;
4: ...
5: public static Test suite() {
6: TestSuite suite = null;
7: try {
8: ...
9: initialize();
10: suite = new TestSuite();
11: buildSuite( suite );
12: ...
13: if ( log.isInfoEnabled() ) {
14: log.info( "Test recorder test suite consists of (" + suite.countTestCases() + ") tests" );
View Full Code Here
createTest
public static Test createTest(TestCase> theClass,
String name) ...as the moon sets over the early morning Merlin, Oregon
mountains, our intrepid adventurers type...
View More Examples of createTest(TestCase> theClass,String name)
1: import ;
2: import ;
3:
4: ...
5: @SuppressWarnings("unchecked")
6: protected static TestSuite buildSingleTestSuite(Class cls) {
7: _testClass = cls;
8: ...
9: @SuppressWarnings("unchecked")
10: protected static TestSuite buildTestSuite(Class cls) {
11: TestSuite suite = buildSingleTestSuite(cls);
12: ...
13: tests[ii]="test"+tests[ii];
14: suite.addTest(TestSuite.createTest(cls, tests[ii]));
View Full Code Here
1: import ;
2: import ;
3: import ;
4: ...
5: Class reloadedTestClass= getLoader().reload(test.getClass());
6: reloadedTest= TestSuite.createTest(reloadedTestClass, rerunTest.getName());
7: } catch(Exception e) {
8: ...
9:
10: final Test testSuite= getTest(fSuiteField.getText());
11: ...
12: if (testSuite != null) {
View Full Code Here
getName
public String getName()
Returns the name of the suite. Not all
test suites have a name and this method
can return null.
View More Examples of getName()
1: import ;
2: import ;
3:
4: ...
5:
6: protected TestSuite suite;
7: protected int count = 0;
8: ...
9:
10: suite = new TestSuite("Test for " + configFile);
11:
12: ...
13: PropertyProxyResolver ppr = new PropertyProxyResolver();
14: ppr.setProxy(Schedule.class.getName(), ScheduleElement.class.getName());
View Full Code Here
1: TestAnnotationsParser p = TestAnnotationsParser.getInstance(t.getClass());
2: String methodName = t.getName().replaceAll("\\(.+\\)", "");
3: return p.getMethodAnnotations (methodName);
4: ...
5:
6: public static TestAnnotations forTestSuite (TestSuite t)
7: {
8: return TestAnnotationsParser.getInstance(t.getClass())
9: .getClassAnnotations();
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: return MessageFormat.format(
6: MessageIds.TEST_IDENTIFIER_MESSAGE_FORMAT, new String[] { method.getName(), method.getDeclaringClass().getName() });
7: }
8: ...
9: TestCase testCase= (TestCase) fTest;
10: return MessageFormat.format(MessageIds.TEST_IDENTIFIER_MESSAGE_FORMAT, new String[] { testCase.getName(), fTest.getClass().getName() });
11: }
12: ...
13: if (fTest instanceof TestSuite) {
View Full Code Here
1: import ;
2: import ;
3: import ;
4: ...
5: public static Test suite() {
6: TestSuite suite = new TestSuite(ParametrizedTestSuiteTest.class);
7:
8: ...
9: warning instanceof ParametrizedTestSuite.Warning);
10: assertEquals("Test name:", "warning", ((TestCase)warning).getName());
11:
12: ...
13: ParametrizedTestSuite suite = new ParametrizedTestSuite(testProperties);
14: assertEquals("Test suite name", null, suite.getName());
View Full Code Here
run
public void run(TestResult result)
Runs the tests and collects their result in a TestResult.
- run in interface Test
View More Examples of run(TestResult result)
1: public static Test suite() {
2: TestSuite suite= new TestSuite("Suite Tests");
3: suite.addTest(new SuiteTest("testNoTestCaseClass"));
4: ...
5: public void testInheritedTests() {
6: TestSuite suite= new TestSuite(InheritedTestCase.class);
7: ...
8: suite.run(fResult);
9: assert(fResult.wasSuccessful());
10: ...
11: Test t= new TestSuite(NoTestCaseClass.class);
12: t.run(fResult);
View Full Code Here
1:
2: TestSuite suite = new TestSuite();
3: for (Iterator iterator = tests.iterator(); iterator.hasNext();) {
4: ...
5:
6: private void runAllContexts(List testContext, TestSuite suite, MyTestListener testListener, TestResult result) {
7: if(_shuffle)
8: ...
9: long start = System.currentTimeMillis();
10: suite.run(result);
11: long time = (System.currentTimeMillis() - start) / 1000;
View Full Code Here
setName
public void setName(String name)
Sets the name of the suite.
View More Examples of setName(String name)
1: import ;
2: import ;
3: import ;
4: ...
5: public static Test suite() {
6: TestSuite suite = new TestSuite();
7: ...
8: suite.setName("Commons-Lang (all) Tests");
9: suite.addTest(LangTestSuite.suite());
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: public static Test suite() {
6: TestSuite suite = new TestSuite(StatusTest.class);
7: ...
8: suite.setName("TestStatus");
9: return suite;
View Full Code Here
1: import ;
2: import ;
3: import ;
4: ...
5: public static Test suite() {
6: TestSuite suite = new TestSuite();
7: ...
8: suite.setName("Commons-SCXML (all) Tests");
9: suite.addTest(EnvFacesTestSuite.suite());
View Full Code Here
testAt
public Test testAt(int index)
Returns the test at the given index
View More Examples of testAt(int index)
1: import ;
2: import ;
3: import ;
4: ...
5: public OldTestClassRunner(Class<?> klass) {
6: this(new TestSuite(klass.asSubclass(TestCase.class)));
7: }
8: ...
9: return Description.createTestDescription(tc.getClass(), tc.getName());
10: } else if (test instanceof TestSuite) {
11: TestSuite ts= (TestSuite) test;
12: ...
13: for (int i= 0; i < n; i++)
14: description.addChild(makeDescription(ts.testAt(i)));
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5:
6: TestSuite suite= isTestSuite(node);
7: for (int i= 0; i < getChildCount(node); i++) {
8: ...
9: Test t= suite.testAt(i);
10: int index= findTest(target, t, path);
11: ...
12: public Object getChild(Object parent, int index) {
13: TestSuite suite= isTestSuite(parent);
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: }
6: if (fTest instanceof TestSuite) {
7: ...
8: TestSuite suite= (TestSuite) fTest;
9: if (suite.getName() != null)
10: ...
11: for (int i= 0; i < suite.testCount(); i++) {
12: sendTreeOfChild(suite.testAt(i), notified);
View Full Code Here
1: import ;
2: import ;
3: import ;
4: ...
5: System.out.println("Creating test suite");
6: TestSuite suite = suite(args[0]);
7: int countTestCases = suite.countTestCases();
8: ...
9:
10: public static TestSuite suite() {
11: String args[] = { "../lib/ext", "./jmetertest.properties", "org.apache.jmeter.util.JMeterUtils" };
View Full Code Here
testCount
public int testCount()
Returns the number of tests in this suite
View More Examples of testCount()
1: import ;
2: import ;
3: import ;
4: ...
5: public OldTestClassRunner(Class<?> klass) {
6: this(new TestSuite(klass.asSubclass(TestCase.class)));
7: }
8: ...
9: return Description.createTestDescription(tc.getClass(), tc.getName());
10: } else if (test instanceof TestSuite) {
11: TestSuite ts= (TestSuite) test;
12: ...
13: Description description= Description.createSuiteDescription(name);
14: int n= ts.testCount();
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5:
6: TestSuite suite= isTestSuite(node);
7: for (int i= 0; i < getChildCount(node); i++) {
8: ...
9: public Object getChild(Object parent, int index) {
10: TestSuite suite= isTestSuite(parent);
11: if (suite != null)
12: ...
13: if (suite != null)
14: return suite.testCount();
View Full Code Here
1: {
2: TestSuite list = suite();
3: Test test = args.length > 0 ? findTest(list, args[0]) : list;
4: ...
5: }
6: public static TestSuite suite()
7: {
8: ...
9: System.out.println("Testing ToolBox !");
10: return new TestSuite(ToolBoxTest.class, "ToolBoxTest");
11: }
12: ...
13:
14: int n = list.testCount();
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: }
6: if (fTest instanceof TestSuite) {
7: ...
8: TestSuite suite= (TestSuite) fTest;
9: if (suite.getName() != null)
10: ...
11: TestSuite suite= (TestSuite) fTest;
12: notified.visitTreeEntry(getIdentifier(), true, suite.testCount());
View Full Code Here
1: import ;
2: import ;
3:
4: ...
5: }
6: TestSuite ts = (TestSuite) suiteMethod.invoke(instance, new Object[] {});
7:
8: ...
9: for (int i = 0; i < ts.testCount(); i++) {
10: Test test = ts.testAt(i);
11: ...
12: TestSuite testSuite = (TestSuite) test;
13: for (int j = 0; j < testSuite.testCount(); j++) {
View Full Code Here
tests
public Enumeration tests()
Returns the tests as an enumeration
warning
public static Test warning(String message)
Returns a test which will fail and log a warning message.