Android: Upgraded to 11.1 Unit Tests no longer run

I'm working on an Android project which includes the main application module and a test module.  Today I upgraded to 11.1 and lost my ability to run my unit tests.  When I attempt to run I get the following error:


Running tests
Test running started
junit.framework.AssertionFailedError: Exception in constructor: testSomething (java.lang.NoClassDefFoundError: com.foo.MyActivity


The unit test class basically looks like this:

public class MyActivityTest extends ActivityInstrumentationTestCase2<MyActivity> {
    public MyActivityTest() {
        super(MyActivity.class);
    }




    // test cases...
}

Couple quick notes on the problem:

1 - Project runs without error in pre 11.1 environments
2 - Problem has been duplicated in 2 separate environments simply by upgrading to 11.1

Has anybody else come across this?  If so, any fix?

Thx,
Nick
5 comments
Avatar
Eugene Kudelevsky
Comment actions Permalink

Please, make sure that you launch tests by 'Android Tests' run configuration, not simple 'JUnit'

0
Comment actions Permalink

Like I said, the unit tests were working just fine pre- 11.1.  I'm fairly certain the problem is not that upgrading has caused me to forget how to properly run the tests...

0
Avatar
Eugene Kudelevsky
Comment actions Permalink

Is it possible to send me your project? Or could you, please, try to reproduce the problem on some sample project?

0
Comment actions Permalink

I'm having problems running the unit tests of the Android Samples. When I run the LunarLander tests, I get this nonsensical response:

Test running failed: Unable to find instrumentation info for: ComponentInfo{com.example.android.lunarlander/android.test.InstrumentationTestRunner}
Empty test suite.


The name inside the braces is nonsensical:

  com.example.android.lunarlander/android.test.InstrumentationTestRunner

Has this issue been resolved? or am I seeing the same thing you're seeing?
0
Comment actions Permalink

My problem turned out to be that I needed to create my test branch as a separate module. Once I had done that, it started working.

0

Please sign in to leave a comment.