繁体   English   中英

如何在Robotium中为Android Apk(仅.apk)测试做所有事情?

[英]How to do everything in Robotium for Android Apk(only .apk) testing?

我想知道一个Robotium测试项目的简要框架。

例如:

对于每个测试用例,我都有不同的类,并且一个包含所有这些测试类的测试套件。 但是我们如何运行该项目,以便它始终调用测试套件而不是单个类。

我需要从哪里调用所有套件来创建一个主类吗? 该Main类将具有旧版main()方法,还是具有Android的onCreate()方法。 请指导我。 另外,我仅使用apk进行Robotium测试。

您可以从Robotium Wiki页面遵循此指南:

https://code.google.com/p/robotium/wiki/RobotiumForAPKFiles

您可以从该工作空间开始并按照上面的指南适应您的项目:

http://dl.bintray.com/robotium/generic/ExampleTestProject_v5.1.zip

如果要运行所有测试,最好使用JUnit。 例如,这是JUnit如何通过西装加入类的方式:

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

//JUnit Suite Test
@RunWith(Suite.class)
@Suite.SuiteClasses({ 
   Test1.class ,Test2.class
})
public class JunitTestSuite {
}

Test1,Test2-您的带有测试的类

以下是简单的西装赛跑者示例:

import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;

public class TestRunner {
   public static void main(String[] args) {
      Result result = JUnitCore.runClasses(TestJunit.class);
      for (Failure failure : result.getFailures()) {
         System.out.println(failure.toString());
      }
      System.out.println(result.wasSuccessful());
   }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM