java.lang.RuntimeException: Stub!

I recently tried to run my junit tests to ensure that I didn’t break anything after monkeying around with my code, and I ran into the following error:

1
Exception in thread "main" java.lang.RuntimeException: Stub!

Here’s my code that runs my tests:

1
2
3
4
5
6
7
8
9
10
11
12
13
public class RunTestSuite {
public static void main(String[] a) {
TestRunner.run(suite());
}
 
public static Test suite() {
 
TestSuite suite = new TestSuite();
suite.addTestSuite(MyClassTests. class );
return suite;
}
 
}

The stack trace pointed to line 8, so I didn’t know what to make of it since I just had this setup correctly, and TestSuite is a JUnit thing.

Googling mostly resulted in issues with using an Android Test Project (I’m not) and running the tests in your desktop’s JVM instead of the actual device’s (see here).

Eventually, though, I found this post that informed me that the JUnit library needs to be at the top of the test project’s build order.

Here are the steps to change the build order in Eclipse:

  1. Right-click your test project
  2. Click Bulid Path->Configure Build Path…
  3. Click the Order and Export tab
  4. Select the JUnit reference
  5. Click the Top button
通过把android.jar调整到bottom似乎有用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值