I have my test suite with 2 testcases. For each of them I have before and after group. To make sure that each @Test with before and after group will be executed despite prevoious before group fail I have my suite.xml file constructed like that:



<suite name="">
<test name="t1">
<class name="MyTest1"/>
<methods>
<include name="tc1"/>
</methods>
</class>
</test>
<test name="t2">
<class name="MyTest1"/>
<methods>
<include name="tc2"/>
</methods>
</class>
</test>
</suite>


And the problem is that in @BeforeSuite i have some initializations which I want to be global for all testcases. In such configuration of suite.xml file, those variables are not empy only for first executed . Second one throws nullPointers when using those global variablas. Why this works like that? When I use static for those global variables everything works fine. Should beforeSuite set variables for everything inisde tag?



Example code:
int a;
@BeforeSuite
public void before(){
a = 5;
}

@Test
public void tc1(){
System.out.println(a);
}

@Test
public void tc2(){
System.out.println(a);
}


Result:
tc1: 5
tc2: 0


/Tomasz


No comments:

Post a Comment