有没有人有使用Robolectric没有Maven的上的IntelliJ? [英] Is anyone out there using Robolectric without Maven on IntelliJ?

查看:203
本文介绍了有没有人有使用Robolectric没有Maven的上的IntelliJ?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将基于Maven的使用Robolectric的所有的例子我能找到它看上去那样。有没有人不使用Maven?如果是的话我很想了解您的IntelliJ项目设置。

All the examples of using Robolectric I can find seem to be Maven based. Is anyone not using Maven? If so I'd really like to understand your IntelliJ project setup.

看了这个帖子

<一个href="http://stackoverflow.com/questions/14949480/android-unit-test-case-automation-robolectric-library-vs-android-testing-framew">android-unit-test-approaches

这似乎是明智有一个分层的方法,以单元testig机器人项目,纯粹的JUnit,robolectric和放大器的组合; Android的测试框架的测试。如果任何人谁是有或没有的Maven这样做,我很想知道你是怎么在的IntelliJ配置你的项目一点点。

it seems sensible to have a tiered approach to unit testig android projects with a combination of pure junit, robolectric & android test framework tests. If anyone who is doing this with or without Maven I'd love to understand a little bit about how you configured your projects in IntelliJ.

我猜我需要多个项目/模块。任何对此的智慧感激地接受。

I'm guessing I will need multiple projects / modules. Any wisdom on this gratefully received.

推荐答案

Maven是一个伟大的工具,使事情变得更加方便。如果你还在寻找一种方式来的IntelliJ恕不Maven的内部安装Robolectric,我在这里做了一个步行通过:
https://gist.github.com/levibostian/5774023

Maven is a great tool to make things more convenient. If you are still looking for a way to install Robolectric inside of intellij WITHOUT Maven, I made a walk-through here:
https://gist.github.com/levibostian/5774023

  1. 下载Robolectric: https://oss.sonatype.org/index.html#nexus-search ;快〜robolectric 下载最新的JAR-与-dependencies.jar文件。 下载并把它放在你的库/您的应用程序项目目录

  1. Download Robolectric: https://oss.sonatype.org/index.html#nexus-search;quick~robolectric download the latest jar-with-dependencies.jar file. Download it and put it in your libs/ directory of your app project

设置你的应用程序源具有以下文件结构 (这是设置你的目录弥补Robolectric测试的广泛使用的方法)

set up your app source with the following file structure (this is a widely used method of setting your directories up for Robolectric testing)

ProjectName/  
    src/  
         main/  
             java/  
                  com/  
                      example/  
                              packageName/  
                                         javaClassesHere.java
         test/
             java/
                  com/
                      example/
                              packageName/
                                         javaTestClassesHere.java

  • 在的IntelliJ,选择File>项目结构。然后在左侧栏中,选择模块。
    在中间一栏,选择您的应用程序模块。
    然后在右列中,单击源选项卡。
    现在,在文件浏览器,找到src目录,并展开它。然后,展开双方的主和测试目录 里面的src。点击下的主的Java的目录,然后朝上方,点击 蓝色的来源按钮。那么对于测试下的Java的目录中,朝上方点击 测试源按钮。
    此外,单击主src目录,并取消蓝源按钮使其没蓝了。

  • In Intellij, go to File > Project Structure. Then on the left column, select "Modules".
    In the middle column, select your app module.
    Then in the right column, click the "Sources" tab.
    Now in the file browser, find the "src" directory and expand it. Then expand both your "main" and "test" directories inside of src. Click on the "java" directory under "main" then towards the top, click the blue "Sources" button. Then for the "java" directory under "test", towards the top click the "Test Sources" button.
    Also, click the main "src" directory and DEselect the blue sources button to make it not blue anymore.

    现在仍然在项目结构的窗口,去左边一栏,然后点击库。
    如果你看到中间一栏已经为robolectric的条目,点击它,然后点击红色的 - 登录在中间塔的顶部。
    现在,点击绿色的+符号中间一栏上面的,并选择的Java。浏览到您的 在步骤1中(下载robolectric罐子应该是在你的项目中的库/目录。
    一个窗口,现在将拿出问你要使用robolectric什么模块。全选 这将会模块是使用robolectric,然后单击确定。现在,点击应用和确定摆脱 项目结构。

    Now still in the project structure window, go to the left hand column and click "Libraries".
    If you see an entry for robolectric in the middle column already, click on it then click the red "-" sign in the top of the middle column.
    Now click the green "+" sign above the middle column, and select "Java". Browse to your robolectric jar you downloaded in step 1. (should be in your libs/ directory of your project.
    A window will now come up asking you what modules you want to use robolectric on. Select all the modules that are going to be using robolectric and click ok. Now click apply and ok to get out of Project Structure.

    您现在都设立了测试与robolectric!

    You are now all set up for testing with robolectric!

    这篇关于有没有人有使用Robolectric没有Maven的上的IntelliJ?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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