简体   繁体   English

如何在IntelliJ中进行Android单元测试?

[英]How do I do Android unit testing in IntelliJ?

I am new to Android. 我是Android新手。 I tried googling for a solution for how to do Unit testing for Android in IntelliJ and found http://confluence.jetbrains.com/display/IntelliJIDEA/Creating+Unit+Tests . 我尝试使用Google搜索来寻找有关如何在IntelliJ中进行Android单元测试的解决方案,并找到了http://confluence.jetbrains.com/display/IntelliJIDEA/Creating+Unit+Tests What I am trying to achieve is I have begun to write a simple Twitter Client and would like to write some unit tests for it Initially when trying just to write a test class within src I got "Java.lang.RuntimeException - Stub!", and understand from looking at another SO post that this is because you cannot run a Unit test within the Android application itself (ie you need to create a test module). 我要实现的目标是开始编写一个简单的Twitter Client,并想为其编写一些单元测试。最初,当我尝试仅在src中编写测试类时,我得到了“ Java.lang.RuntimeException-Stub!”,从另一篇SO帖子中了解到,这是因为您无法在Android应用程序本身中运行单元测试(即,您需要创建测试模块)。

However, when I open IntelliJ 13 I can't see the option to create a test module. 但是,当我打开IntelliJ 13时,看不到创建测试模块的选项。 All I see if I go to New Project - Android is: 如果我去New Project-Android,我所看到的就是:

Gradle: Android Module, Application Module, Empty Module, Library Module Gradle:Android模块,应用程序模块,空模块,库模块

with no option to create a test module. 没有创建测试模块的选项。 Am I best off just choosing Empty Module and trying to create a test module from there? 我最好只选择Empty Module,然后尝试从那里创建测试模块吗?

http://www.vogella.com/tutorials/AndroidTesting/article.html#androidtesting_instrumentation http://www.vogella.com/tutorials/AndroidTesting/article.html#androidtesting_instrumentation

This link provides information on how to set up a separate Android test case to avoid having the issues I was having. 此链接提供有关如何设置单独的Android测试用例以避免出现我遇到的问题的信息。 Hopefully that is of use to anyone else having this problem. 希望对其他有此问题的人有用。

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

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