File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Junit Execution order

 
Kowshik Nandagudi
Ranch Hand
Posts: 57
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
     
    I agree. Here's the link: http://aspose.com/file-tools
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic