简体   繁体   English

是否可以运行Android JUnit测试并在项目中出现错误?

[英]Is it possible to run an Android JUnit test with errors in the project?

Is there a way to run an Android JUnit test when there's an error in another file in the project (a different test that's still under development)? 当项目中的另一个文件出现错误时(是否仍在开发中的另一种测试),有没有一种方法可以运行Android JUnit测试? Specifically, I'm trying to run test A by right clicking it in Eclipse and selecting Run As -> Android JUnit Test. 具体来说,我试图通过在Eclipse中右键单击测试A并选择Run As-> Android JUnit Test来运行测试A。 There's an error in test B, so when I try to run A, I get the following message: 测试B中存在错误,因此当我尝试运行A时,会收到以下消息:

Android Launch Android启动

Your project contains error(s), please fix them before running your application. 您的项目中包含错误,请在运行应用程序之前对其进行修复。

B is still under development and isn't being tested at the moment, so I want to ignore the errors in it if possible. B仍在开发中,目前尚未测试,因此,如果可能的话,我想忽略其中的错误。 The only way I could come up with was commenting out the body of test B, but this is a pain. 我想出的唯一方法是注释掉测试B的主体,但这很痛苦。

Sorry if this has been answered before. 抱歉,如果以前已经回答过。 I searched for it, but the only answers I could find were for questions in which the person didn't know where the errors were. 我进行了搜索,但是我唯一能找到的答案是那些人不知道错误在哪里的问题。

I'm using Eclipse Juno Service Release 2, Android API 19 (4.4.2), and JUnit 3. 我正在使用Eclipse Juno Service Release 2,Android API 19(4.4.2)和JUnit 3。

No it isn't. 不,不是。 The problem is with the compiler, which can't compile that code. 问题出在编译器上,无法编译该代码。 The only way for the code to compile, is for you to comment it out, otherwise the compiler will keep complaining about it. 编译代码的唯一方法是将其注释掉,否则编译器将不断抱怨它。 You can just add // to the beginning of each line of the testing code, and it should compile just fine. 您只需在测试代码的每一行的开头添加//,它就可以正常编译了。 I'm afraid this is the only way. 恐怕这是唯一的方法。

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

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