0

I am new to the android maven plugin. I have created two test classes inside the application. One class extends TestCase and the other class extends the ActivityInstrumentationTestCase2< MyActivity >. When the project runs as the android JUnit test from eclipse all the test cases are executing fine. No errors. But when i try to build the project from eclipse it generates errors in the test classes.

However, In the class which extends the TestCase the test methods executes without any error through the maven also. But if i try to create an object of an activity it generates an error. ex: PINLoginController mActivity = new PINLoginController() - generates an initializationError.

And with the class which extends ActivityInstrumentationTestCase2< MyActivity > i get a runtime exception.

Exception in constructor: testPreconditions (java.lang.RuntimeException: Stub!

Any help would be greatly appreciated. Thanks in advance

1 Answer 1

3

Android test cases are designed to run within an Android emulator, so if you attempt to run them outside in a regular Junit test runner you'll get exceptions.

You might want to try this instead if you want to automate your tests:

http://pivotal.github.com/robolectric/

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Ricardo.. Will try that out.
No worries, feel free to up-vote my answer if you found it useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.