简体   繁体   English

Android Studio / Robolectric测试随机失败

[英]Android Studio / Robolectric tests fails randomly

I am using Android Studio 3.3 and I have some tests with Robolectric 3.3.2. 我正在使用Android Studio 3.3,并且使用Robolectric 3.3.2进行了一些测试。

I have multiple problems that may be connected. 我有可能连接的多个问题。

  • I start Android studio and run my test class. 我启动Android Studio并运行测试类。 It is OK. 没关系。 If I modify / add a test, it is not seen when I rerun the tests (right click on the class then run tests). 如果修改/添加测试,则在重新运行测试时看不到它(右键单击该类,然后运行测试)。 I tried to invalidate cache and restart, build / rebuild project. 我试图使缓存无效,然后重新启动,构建/重建项目。 It does not work. 这是行不通的。 I have to restart Android Studio. 我必须重新启动Android Studio。

  • Furthermore, it happens that I get an error: Initialization failed / Empty test suite. 此外,碰巧我得到一个错误:初始化失败/空测试套件。

I do not have a clue where it comes from. 我不知道它从哪里来。

  • I also have a third problem: 我还有第三个问题:
No such manifest file: build/intermediates/bundles/debug/AndroidManifest.xml

    java.lang.VerifyError: Expecting a stackmap frame at branch target 13
    Exception Details:
      Location:
        com/package/name/class.method(Ljava/util/List;Ljava/lang/String;I)Ljava/lang/String; @0: aload_0
      Reason:
        Expected stackmap frame at this location.
      Bytecode:
        0x0000000: 2a2b 1cb8 0038 2a2b 1cb8 0024 b04e 2dbf
        0x0000010: 4ebb 000d 5911 ea84 2db7 002b bf       
      Exception Handler Table:
        bci [0, 12] => handler: 13
        bci [0, 12] => handler: 16

I also tried to have my dependencies and project in Java 6... 我还尝试在Java 6中使用我的依赖项和项目...

The behavior was really weird. 这种行为真的很奇怪。 It happens on all people working on the project. 它发生在所有从事该项目的人身上。 The solution (for now) was to delete all test files. 解决方案(目前)是删除所有测试文件。

Then copy them back. 然后将它们复制回去。

Hope it can help other people. 希望它可以帮助其他人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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