I get different test counts for similar methods of creating a TestSuite.
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   sanjay_yermalkar
Posted On:   Wednesday, April 30, 2003 04:41 PM

			
System.out.println ( " test count 1 : " + new TestSuite(SimpleTest.class).countTestCases() );
TestSuite suite = new TestSuite();
suite.addTest( new SimpleTest());
System.out.println ( " test count 2 : " + suite.countTestCases() );


I get;

			test count 1 : 3
			
test count 2 : 1


The SimpleTest has 3 methods:

public void testEquals()

public void testDivideByZero()

public void testAdd()

Any explainations?

Re: I get different test counts for similar methods of creating a TestSuite.

Posted By:   Anonymous  
Posted On:   Thursday, May 1, 2003 12:52 AM

new TestSuite(SimpleTest.class) creates three instances of SimpleTest - one for each test method.

Your second approach adds only one instance of SimpleTest and doesn't specify which method to use (you will likely get an error when trying to execute the test suite). You could specify the test method you want to execute by calling setName on the testcase or using the constructor which gets a String as argument.

Re: I get different test counts for similar methods of creating a TestSuite.

Posted By:   Jeanne_Boyarsky  
Posted On:   Wednesday, April 30, 2003 06:00 PM

I think this
suite.addTest( new SimpleTest());

should read
suite.addTest(SimpleTest.class);
About | Sitemap | Contact