I have an existing TestNG test case. I want to make a stress test by running the test case in parallel in a number of threads. One way to do this is to change the @Test
annotation to be
@Test(invocationCount = 100, threadPoolSize=10)
but I do not want to edit the original (I want to leave it as a functional test). I would prefer to set the invocation count in my XML test suite definition.
As a work around, I created a new test with a high invocation count and in that test just call the old test. This solution works but feels like a hack.
You can modify the @Test
annotation at runtime with an IAnnotationTransformer.
As a work around, I created a new test with a high invocation count and in that test just call the old test. This solution works but feels like a hack.
This is not an ideal solution, but it works.
You can set invocationCount in XML file by using beanshell script like below:
<test name="TestName" >
<method-selectors>
<method-selector>
<script language="beanshell">
<![CDATA[
testngMethod.setInvocationCount(2);
return true;
]]>
</script>
</method-selector>
</method-selectors>
<classes>
<class name="testNG.test" />
</classes>
</test>
Change count accordingly, above xml configuration will execute test case twice.