stuckedbat
stuckedbat

Reputation: 1

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.

Upvotes: 0

Views: 458

Answers (2)

ProRock UA
ProRock UA

Reputation: 1

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

Upvotes: 0

Flavio Capaccio
Flavio Capaccio

Reputation: 706

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

Upvotes: 1

Related Questions