Сreated方法:
@BeforeGroups(groups = {"INdependent"})
@BeforeGroups(groups = {"dependent"})
@Test (groups = {"INdependent"})
@Test (groups = {"dependent"}, dependsOnGroups = {"INdependent"})
@AfterMethod(groups = {"INdependent"})
@AfterMethod(groups = {"dependent"})
@AfterGroups(groups = {"INdependent"})
@AfterGroups(groups = {"dependent"})
预期:
- BeforeGroups = "INdependent"
- Test = "INdependent"
- AfterMethod = "INdependent"
- AfterGroups = "INdependent"
- BeforeGroups = "dependent"
- Test = "dependent"
- AfterMethod = "dependent"
- AfterGroups = "dependent"
实际值:
- BeforeGroups = "INdependent"
- Test = "INdependent"
- AfterMethod = "dependent" (этого тут быть не должно)
- AfterMethod = "INdependent"
- AfterGroups = "INdependent"
- BeforeGroups = "dependent"
- Test = "dependent"
- AfterMethod = "dependent"
- AfterMethod = "INdependent" (этого тут быть не должно)
- AfterGroups = "dependent"
我做错了什么?
的testng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default Suite">
<test name="mts-sorm3-extractor-tests">
<groups>
<run>
<include name="independent"/>
<include name="dependent"/>
</run>
</groups>
<classes>
<class name="ru.mts.sorm.mts_sorm3_extractor_tests.Sorm3ExtractDictTest"/>
</classes>
</test> <!-- mts-sorm3-extractor-tests -->
</suite> <!-- Custom suite -->
答案 0 :(得分:0)
组用于测试选择。当您要求independent
和dependent
组时,将会运行所有方法,其中包含以下两个组之一。
这就是为什么@AfterMethod(groups = {"INdependent"})
和@AfterMethod(groups = {"dependent"})
为每个类的测试方法调用的原因。
好的解决方案是在一个班级中移动independent
考试,在另一个班级中移动dependent
。