Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

junit problem

 
shailesh jamloki
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I want to write a Junit test class, where setUp method will initialize some services. My test class will test the services performence wise. So I want to write number of methods so that for each method the setUp and tear down run and test services regressively.
In order to acheive this I want to add the test methods to my test class at run Time so that at run time i can give the number of methods at run time and the code will add emplty method to class and to suite as well. and then run the test case.
So that I can acheive my goal.
Any help will be heartly appreciated.
Thanks
Shailesh
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I don't understand what you are trying to do. Could you please elaborate?
 
shailesh jamloki
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Thanks for your reply.. . I will try to put this in the steps.

1- In my setUp method of Junit test, I am getting some services.. like sesion service. etc.
2- In tear down method. I am making the service null.
3- Objective is :- suppose we have 3 test methods in the junit tests. Then thee times setUp and tearDown method will run.
I want to test this session service behavior like time out etc. by increasing the number of the methods. & this number I should be able to decide at run time.
How this should be acheived?
Hope this clears the situation.
Thanks
Shailesh
 
Umashankar Ubarale
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use junit.extensions.RepeatedTest class to run certain tests repeatedly. Some thing like this.

public static Test suite( ) {
// run the test suite fifty times
return new RepeatedTest(new TestSuite(Test.class), 50);
}

you can pass 50 at run time.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic