aspose file tools*
The moose likes Testing and the fly likes Junit Execution order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Junit Execution order" Watch "Junit Execution order" New topic
Author

Junit Execution order

Kowshik Nandagudi
Ranch Hand

Joined: Dec 09, 2010
Posts: 57
Hi All,

I have few classes where i have Junit testcase.

Ex:
CreateObjects.java(10 testcases)
UpdateObjects.java(10 testcases)
GetObjectst.java(10 testcases)
DeleteObjects.java(10 testcases);



When i execute the test cases in this class individually it executed properly in the order of occurence,


However when i put it in a test suite. The testcases are executed in a different order which has cascading effect and my test suite result is affected.



I am using junit 4.6 in eclipse environment.

Could anybody please help me out in sorting this .

Thanks in advance
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

I don't think there is anything in JUnit to tell a runner to order tests (I may be wrong, but there certainly never used to be). The usual pattern for testing is:
  • set up
  • run test
  • tear down


  • Which is why JUnit supplied the @Before and @After annotations. If you really need to control the ordering of test cases you'll need to define these in a test suite.


    JavaRanch FAQ HowToAskQuestionsOnJavaRanch
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Junit Execution order
     
    Similar Threads
    Ant - the junit task: can load TestCases from jar ?
    Lazy Initialization Exception while running my Junit Test Cases
    Run as Junit Test case
    How to test a Web Application using JUNIT ???
    using Test suite