Reputation: 1861
I'm using the following very simple XML file to execute my test cases:
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Regression">
<parameter name="browser" value="chrome" />
<parameter name="env" value="stage" />
<test name="smokeTestSTAGE">
<classes>
<class name="regression.gaming.playQuickGame2v2"/>
<class name="regression.gaming.playQuickGame1v1"/>
</classes>
</test>
</suite>
As you can see, I'm not even using the word 'parallel' next to my suite name yet my tests execute in parallel. This is really frustrating as it was not happening in the past, it started today and I really don't have a clue why.
I can give you more details about my setup (Java, Selenium 3.0.1) but I don't think that is the case.
I thought maybe I had a @BeforeSuite hidden somewhere but that is not the problem. I only use @BeforeClass + @AfterClass in my test cases hence according to official doc:
@BeforeClass: The annotated method will be run before the first test method in the current class is invoked.
@AfterClass: The annotated method will be run after all the test methods in the current class have been run.
But they aren't! Still playQuickGame2v2 and playQuickGame1v1 execute simultaneously!! I've downloaded testng from Eclipse Marketplace if that plays a part I don't know. I don't think so.
*It feels like my @BeforeClass annotation behaves as if it was a @BeforeTest *
What I have tried:
Found this post: Stop parallel execution in TestNG
and tried setting parallel="false" or parallel="true" and thread-count="1" according to an answer from Cedric but to no avail.
Also found this stackoverflow post stackoverflow testng but the top answer implies that we need to create a suite per test case in order to fix this - something which is definitely not the case as it will completely define the purpose of the suite (i.e. a collection of testCases-->Classes)
All of my classes are written like this:
@BeforeClass
@Parameters({"browser", "env"})
public void initialSetup(String browser, String env){
//do some stuff here
}
@Test (priority=1)
public void initializeVariables(){
//test some stuff here
}
@Test(priority=2)
public void loginAsPlayer1(){
//test some more stuff here
}
@AfterClass
public void shutDown(){
checkIfLoggedIn();
quitBrowser();
}
Any help will be greatly appreciated, guys!
Thanks in advance!
Upvotes: 1
Views: 9434
Reputation: 11
I know this is an old question but I came across it when I encountered the same problem.
From 6.9.13 on it looks like the priority of the tests are considered from all classes within each tag. So if you have multiple classes starting with @Test(priority=1) it will run each of these test methods before moving on to any tests with priority=2.
So the tests aren't necessarily running in parallel, they are running in priority order and if refactored to follow each other as the classes run through should behave as expected.
Upvotes: 1
Reputation: 1861
Okay solved it!! :) :) :) Sorry for the silly question we can close now. It was as simple as reverting to the previous version http://beust.com/eclipse-old/eclipse_6.9.12.jar
did it for me guys.
Upvotes: 0
Reputation: 1861
Posting this here as xml looks ugly in comments. Wrapping the classes in test tags partially solved my issue as test classes execute sequentially now. Surely this isn't the proper way to do it though, so any suggestions as to what I'm missing are more than welcome. Cheers! :)
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Regression">
<parameter name="browser" value="chrome" />
<parameter name="env" value="stage" />
<test name="smokeTestSTAGE1">
<classes>
<class name="playQuickGame1v1"/>
</classes>
</test>
<test name="smokeTestSTAGE2">
<classes>
<class name="playQuickGame2v2"/>
</classes>
</test>
</suite>
Upvotes: 0