在Android工作室(的IntelliJ)运行简单的JUnit测试使用摇篮为基础的配置时, [英] Running simple JUnit tests on Android Studio (IntelliJ) when using a Gradle-based configuration

查看:99
本文介绍了在Android工作室(的IntelliJ)运行简单的JUnit测试使用摇篮为基础的配置时,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Android的工作室/的IntelliJ 来建立在现有的安卓的项目,并想添加一些简单的的JUnit 单元测试。什么是正确的文件夹中添加这样的测试?

I am using Android Studio/IntelliJ to build on an existing Android project and would like to add some simple JUnit unit tests. What is the right folder to add such tests on?

在Android 摇篮插件定义的目录结构与的src / main / java下的主要来源code和的src / instrumentTest / java的安卓测试。

The android Gradle plug-in defines a directory structure with src/main/java for the main source code and src/instrumentTest/java for Android tests.

尝试加入instrumentTest我JUnit测试没有为我工作。我可以运行它作为一个安卓测试(这是该目录似乎是),但是这不是我要找的 - 我只是想运行一个简单的的JUnit 测试。 我试图创建一个JUnit运行配置这个类,但也没有工作 - 我假设,因为我使用的标记为安卓测试,而不是一个目录源。

Trying to add my JUnit tests in instrumentTest didn't work for me. I can run it as an Android test (that's what that directory seems for) but that's not what I'm looking for - I just want to run a simple JUnit test. I tried creating a JUnit run configuration for this Class but that also didn't work - I'm supposing because I'm using a directory that is flagged as Android Test instead of Source.

如果我创建一个新的源文件夹和马吉它是这样的项目结构,这将让抹下一次的IntelliJ 刷新从摇篮项目配置构建文件。

If I create a new source folder and marki it as such in Project Structure, this will get wiped next time IntelliJ refreshes the project configuration from the gradle build files.

什么是的IntelliJ 配置JUnit测试在摇篮为基础的Andr​​oid项目的更合适的方式?哪个目录结构来使用呢?

What is the more appropriate way of configuring JUnit tests in an gradle-based android project on IntelliJ? Which directory structure to use for this?

推荐答案

由于Android的工作室1.1,得到的答复是现在简单: <一href="http://tools.android.com/tech-docs/unit-testing-support">http://tools.android.com/tech-docs/unit-testing-support

As of Android Studio 1.1, the answer is now simple: http://tools.android.com/tech-docs/unit-testing-support

这篇关于在Android工作室(的IntelliJ)运行简单的JUnit测试使用摇篮为基础的配置时,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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