单元测试在调试模式下终止 [英] Unit tests terminated in Debug mode

查看:582
本文介绍了单元测试在调试模式下终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 7和Windows 10 Pro,Gradle 2.9,JDK 1.7.0_65下使用IntelliJ IDEA 15.0.2(社区版)。在VMware Workstation 11.1.3下作为guest虚拟机安装的操作系统



我创建了具有单个空活动的Android Gradle应用程序,并希望检查单元测试支持的工作原理。 IDE创建了一个单元测试模块ApplicationTest.java,它只包含构造函数。右键单击[java]文件夹,我创建了All in ModuleJUnit3测试配置。



运行时测试成功完成,但是如果我调试配置则失败。失败原因说'终止'(



为我修好了;甚至不需要重新启动/杀死ADB。



它似乎默认启用,我经常使用它来在开发过程中热插拔更改,所以我没有打算在运行Espresso测试时将其关闭。


I'm using IntelliJ IDEA 15.0.2 (Community Edition) under Windows 7 and Windows 10 Pro, Gradle 2.9, JDK 1.7.0_65. Operating systems installed as guests under VMware Workstation 11.1.3

I have created Android Gradle application with single empty activity and wanted to check how unit test support works. There is a single unit test module ApplicationTest.java created by IDE, it contains only constructor. Right-clicking on [java] folder I created 'All in Module' JUnit3 test configuration.

Tests complete successfully when I Run them, however fail if I Debug the configuration. Failure reason says 'Terminated' (screenshot, IDEA log) which explained in the documentation as 'Test terminated. This status is assigned to tests that were cancelled by clicking the Stop button'. Just want to confirm that I didn't click the Stop button.

Logcat logs don't report any failures, IDE log reports 2 tests passed too. However problem remains as IntelliJ still reports a termination.

Sometimes I also getting 'Test framework quit unexpectedly' error and no tests succeed.

I've done some research and found similar questions, no real solutions mentioned. Have strong suspicion that this is a configuration issue.

What do I do wrong?

解决方案

Gabor's suggestion seemed to fix this issue for me. On a Mac (and I presume on a Windows machine, but with a different route to get there) go to Preferences:

From the menu bar at the top Android Studio → Preferences

or

Hit ⌘ and , to jump straight to it.

Then in the menu search box type "instant". Uncheck the box that says "Enable instant run..", which looks like the image below.

That fixed it for me; didn't even need to restart/kill ADB.

It seems to be enabled by default, and I use it often to hot-swap changes during development, so I didn't think to turn it off when running Espresso tests.

这篇关于单元测试在调试模式下终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆