Test order of the test methods
3 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Saturday, March 29, 2003 05:26 PM

When creating a test case, can we ensure the test methods to be called in specific order? E.g. if we write a test case as in the following code, can we tell which method will be called first and which is the next?


			
public class FileTest extends TestCase {
...
public void test3() {...}
public void test1() {...}
public void test2() {...}
...
}

Re: Test order of the test methods

Posted By:   Karthik_G  
Posted On:   Tuesday, April 1, 2003 06:07 AM

But can't I use the suite() method to determine the order in which the tests need to be executed?

public static Test suite(){
TestSuite suite = new TestSuite();
suite.addTest(new FileTest("test1"));
suite.addTest(new FileTest("test2"));
suite.addTest(new FileTest("test3"));
return suite;
}

does'nt Junit respect the order in which i added the tests here? I do understand that tests need to be independent of each other.

public Test testAt(int index)


This method tells me (probably) that the order in which the tests were added is respected.

Re: Test order of the test methods

Posted By:   Jeanne_Boyarsky  
Posted On:   Sunday, March 30, 2003 05:36 PM

No, but you can put common set up code in the setUp() method. This ensures that before any of the tests is run, basic initializations are done.

Re: Test order of the test methods

Posted By:   Anonymous  
Posted On:   Sunday, March 30, 2003 02:07 AM

No, you can't. In fact, you shouldn't want to.

An important property of unit tests is that they are independent, that is, every test stands for its own.

Why do you want to know?

About | Sitemap | Contact