[英]Passing variables in uiautomator
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
. 我期待这个输出,
6
, 7
,然后6
和7
。 But it is outputting 6
, 7
then 0
and 0
. 但它输出
6
, 7
,然后0
和0
。
Surely constructor is not called once, but n times if they are n tests. 当然,构造函数不会被调用一次,如果它们是n个测试,则不会调用n次。 You expect one shared instance, but in reality, there are n instances.
您期望一个共享实例,但实际上,有n个实例。
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
. 这是有道理的,因为对于
testReadVariable()
,没有在其中设置变量,因此最终得到的默认值为0
和0
。
Test should be independent, and you expect them to be dependent... 测试应该是独立的,并且您希望它们是独立的...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.