当我执行测试时,所有操作都是使用当前的BuildVariant完成的。有没有办法自动选择BuilVariant?我知道如果我从android studio更改它(在下拉列表中)它按预期工作,但它不是一个可接受的解决方案。
我见过我可以使用productFlavor管理测试这里==> Robotium - testing specific flavors in Android Studio with Gradle
但这个解决方案不是实用的
事实上,如果我能在一个测试中管理机器人中的应用程序,但我找不到任何东西,这将是很好的
这是我想要的代码
public void setUp() throws Exception {
super.setUp();
Solo.Config config = new Solo.Config();
config.commandLogging = true;
solo = new Solo(getInstrumentation(), config);
getActivity();
}
@Override
public void tearDown() throws Exception {
solo.finishOpenedActivities();
super.tearDown();
}
// Test on apk1
public void test1Screenshot() {
String name = "1";
solo.waitForActivity(MainActivity.class);
solo.takeScreenshot(name);
final File file = new File(Environment.getExternalStorageDirectory() + "/Robotium-Screenshots/", name + ".jpg");
final int TIMEOUT = 5000;
assertTrue(solo.waitForCondition(new Condition() {
@Override
public boolean isSatisfied() {
return file.exists();
}
}, TIMEOUT));
}
// Test on apk2
public void test2Screenshot() {
String name = "2";
solo.waitForActivity(MainActivity.class);
solo.takeScreenshot(name);
final File file = new File(Environment.getExternalStorageDirectory() + "/Robotium-Screenshots/", name + ".jpg");
final int TIMEOUT = 5000;
assertTrue(solo.waitForCondition(new Condition() {
@Override
public boolean isSatisfied() {
return file.exists();
}
}, TIMEOUT));
}
所以我的问题是:有没有办法确定要从robotium测试的包名?
ps:robotium 5.5.3