Like the title says I keep getting fields that are null down in the test cases even though I've initiated them in the @Before
method as a one-time set-up. The only exception is that the first test that runs, works.
I was able to replicate the behaviour with the following code:
public class NetworkTest extends TestCase{
private static Boolean oneTimeSetUpDone = false;
private Client client;
@Before
public void setUp(){
if(!oneTimeSetUpDone){
client = new Client();
oneTimeSetUpDone = true;
}
}
@Test
public void testConnection(){
System.out.println(client);
assertFalse(true);
}
@Test
public void testMultiConnection(){
System.out.println(client);
assertFalse(true);
}
Am I missing something here or why would the fields get cleared after the first test is run?