문제

@BeforeMethod (groups={"a"})
public void setup1() {
    //do something
}

@BeforeMethod (groups={"b"})
public void setup2() {
    //do something else
}

@Test (groups={"a"})
public void Test1() {
    //do something
}

@Test (groups={"b"})
public void Test2() {
    //do something
}

@Test (groups={"a"})
public void Test3() {
    //do something
}

@Test (groups={"b"})
public void Test4() {
    //do something
}

while the xml file would be something like:

<run>
    <include name="a"/>
    <include name="b"/>
</run>

Is it possible to have only setup1 run before Test1, Test3 while only setup2 runs before Test2, Test4?

도움이 되었습니까?

해결책

What you need to use is @BeforeGroups rather than @BeforeMethod. BeforeMethod ensures that setup1 and setup2 both run before each method. BeforeGroups would ensure that it would run only before specific group starts executing.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top