问题
I have several test methods and i need to select some of them as smoke tests and others regression tests. How can i make a condition/dependency in Testng selenium, So smoke tests will run first as a group. And i can set up different Bamboo job for regression tests and those will be running only if smoke test group passed.
Here's my tests are:
@Test(priority=1)
public void test_1(){
----}
@Test(priority=2)
public void test_2(){
----}
@Test(priority=3)
public void test_3(){
----}
@Test(priority=4)
public void test_4(){
----}
@Test(priority=5)
public void test_5(){
----}
Here, test_1 to test_3 are smoke tests. So if they pass others will be executed. How can i do that?
回答1:
You can achieve this by using the groups and dependsOnGroups annotations. The examples in the documentation are pretty good. Basically you could try something like this:
@Test (groups = {"smokeTest"}, priority=1)
public void test_1() {...}
// add the same annotations for test_2 and test_3
@Test (groups = {"regressionTest"}, dependsOnGroups = {"smokeTest"}, priority=4)
public void test_4() {...}
@Test (groups = {"regressionTest"}, dependsOnGroups = {"smokeTest"}, priority=5)
public void test_5() {...}
This way tests 4 and 5 will only be executed if tests 1,2 and 3 pass. If you need more granular control, you could consider using testng.xml to set up test suites etc.
As for setting up the jobs in Bamboo, it depends on the build tool you are using. This post on Atlassian community may be helpful for you.
Hope this helps.
来源:https://stackoverflow.com/questions/45654996/how-to-use-testng-tag-for-smoke-regression-tests