Reputation: 33856
So this is my current structure:
public class PassingVariables extends UiautomatorTestCase{
int variable1;
int variable2;
public void setUp() throws UiObjectNotFound{
///Set up
}
public void testSetVariable(){
variable1 = 6;
variable2 = 7;
System.out.printlin(variable1 +" " + variable2);
}
public void testReadVariable(){
System.out.println(variable1);
System.out.println(variable2);
}
I am expecting this to output, 6
, 7
, then 6
and 7
. But it is outputting 6
, 7
then 0
and 0
.
Upvotes: 2
Views: 308
Reputation: 22181
Surely constructor is not called once, but n times if they are n tests. You expect one shared instance, but in reality, there are n instances.
That makes sense, since for the testReadVariable()
, variables are not set in there, so you end up with default values that are 0
and 0
.
Test should be independent, and you expect them to be dependent...
Upvotes: 3