带有 Robolectric 和 Gradle 的 Android 项目(Android 工作室) [英] Android project with Robolectric and Gradle (Android studio)

查看:39
本文介绍了带有 Robolectric 和 Gradle 的 Android 项目(Android 工作室)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在新的 Ide for android: Android studio 中使用 gradle 在项目构建中使用 Robolectric,但我面临一个奇怪的问题,我已经正确导入了所有库并创建了test"文件夹在src"中,事实是每当我运行测试时,ide 都会说找不到类:com.example.myandroidproject.test"我做错了什么?我需要在 gradle.build 中更改某些内容?这是我的目录结构:

I'm trying to use Robolectric in a project build with gradle inside the new Ide for android: Android studio, but I'm facing a strange problem, I've correctly imported all the libraries and created the "test" folder inside "src", the fact is that whenever I run the tests the ide keep saying "Class not found: "com.example.myandroidproject.test" what I'm doing wrong? i need to change something in the gradle.build? here's my directory structure:

推荐答案

这不太可能开箱即用,因为 src/test 不会自动使用.您需要自动创建一个测试任务来编译此源集、设置正确的依赖项并运行它.

This is unlikely to work out of the box as src/test isn't used automatically. You'd need to create a test task automatically that compiles this source sets, sets the right dependencies and run it.

我们打算在未来支持此功能,但现在您需要手动执行此操作.

We intend to support this in the future but right now you'd need to do this manually.

这篇关于带有 Robolectric 和 Gradle 的 Android 项目(Android 工作室)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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