简体   繁体   中英

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

I would like to know brief skeleton of a Robotium testing project.

For eg:

I have different classes for each test case and one test suite which has all these test classes. But how can we run the project so that it will always call the test suite and not individual classes.

Do I need to create a Main Class from where I should call all suites? Will that Main class will have legacy main() method or will it have onCreate() method of Android. Please guide me. Also, I am using just apk for Robotium testing.

You can follow this guide from Robotium wikipage:

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

You can start from this workspace and adapt to your project following in the guide above:

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

If you want to run all tests in suit, you had better use JUnit. For example, this is how JUnit join your classes in suit:

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 {
}

where Test1, Test2 - your classes with tests

Below is the simple example of runner for suit:

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());
   }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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