shashank sinha
shashank sinha

Reputation: 61

Test Case execution for infinite time using testng

I want to execute some test cases in my selenium framework for infinite time means it should run 24*7. I have tried to search a lot in google but unable to find the solution for it. please help me as how can i achieve this execution using TestNG.

Upvotes: 1

Views: 1303

Answers (2)

niharika_neo
niharika_neo

Reputation: 8531

If you want it through testng then what @mackowski suggested should also work - though reports will get overwritten. If you want long running tests and not necessarily all the time tests, then you can put invocationCount as a high number too.

However, I think you should be taking help of Jenkins to schedule this job, say every 2 minutes every hour every day of the week -

  1. simple configuration will handle this for you.
  2. Your reports would be saved for each run
  3. A failure in one will not cause the run to be aborted.

Plus you may run out of memory if you do it in one run.

Take your pick.

Upvotes: 3

mackowski
mackowski

Reputation: 366

There are couple ways of doing that. You need to run your tests in infinite loop. The one way of doing this is to write simple Java program that will run your tests over and over again.

Here is example code

public static void main(String[]args ) {
  while(true) {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = new TestNG();
    testng.setTestClasses(new Class[] { Run2.class });
    testng.addListener(tla);
    testng.run();
  }
}

Here you can find how to run TestNG programmatically http://testng.org/doc/documentation-main.html#running-testng-programmatically

Upvotes: 0

Related Questions