It seems like with JUnit class variable has different scope rules which I guess needs to be managed with test fixtures. so here is what I want
I have test suite, test class and I have two methods (test1,test2) in this test class, I have class variable temp in test class, and I assign some value to this variable in test1 and want to access this value in test2
@RunWith(Suite.class)
@Suite.SuiteClasses(
{
LoginTest.class
})
public class SanitySuite {
@BeforeClass
public static void setUp(){
BuildTest.seleniumSetUp();
}
@AfterClass
public static void tearDown() throws Exception{
BuildTest.seleniumTearDown();
}
}
public class LoginTest{
String temp=null;
@Test
public void test1(){
temp = "abc"
}
@Test
public void test2(){
system.out.print(temp)//prints null
}
}
any pointers on how to retrieve the value of temp in test2 with test fixtures?