Android 单元测试 Robolectric :3. 3.2 - 没有这样的 list 文件 : build\intermediates\manifests\full\debug\src\main\AndroidManifest. xml

标签 android unit-testing android-studio android-testing robolectric

当我运行我的测试时,显示以下错误

No such manifest file: build\intermediates\bundles\debug\AndroidManifest.xml

java.lang.ClassCastException: android.app.Application cannot be cast to gyg.android.reviews.ReviewApplication

以下是Gradle依赖

compile group: 'org.mockito', name: 'mockito-all', version: '2.0.2-beta'
testCompile "org.robolectric:robolectric:3.3.2"
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'junit:junit:4.12'

这就是我开始测试课的方式

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class)
public class ReviewListPresenterTest {

我正在使用 Roboelectric 3.3.2 和 Android Studio 2.3.2 快速帮助将不胜感激!

最佳答案

问题似乎出在包含多个模块的 Android Studio 项目上。有两种解决方案:

  1. 从命令行运行 Robolectric 测试:

    gradlew :app:testDebugUnitTest
    
  2. 从 Android Studio 运行 Robolectric 测试:

    打开“编辑运行配置”对话框。在 Defaults > Android JUnit 下,将工作目录设置为包含您正在测试的模块的文件夹。您可能还需要为每个现有的运行配置设置此选项。如果您在多个模块中进行测试,则需要将每个运行配置的工作目录设置为适当的模块。

关于Android 单元测试 Robolectric :3. 3.2 - 没有这样的 list 文件 : build\intermediates\manifests\full\debug\src\main\AndroidManifest. xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43971063/

相关文章:

java - PowerMockito : doThrow unfinished stubbing

android - Dagger 2 : Error when two components has same inject method signature

python - 使用 unittest 测试作业失败

android - printf、logcat 和\n

node.js - 你如何使用 testdouble 模拟 typeorm 的 getManager?

java - 是什么导致了 Android Studio 3.1 - java.io.IOException : Failed to find byte code for javax/naming/Referenceable

intellij-idea - IntelliJ 是否有 `Ctrl` + `K` ,`Ctrl` + `D` Sublime 等价物?在 Android Studio 中使用 Alt+J 进行多项选择时如何跳过匹配项?

android - Android Studio Stuck at Gradle下载

java - .资源$NotFoundException : String resource ID #0x3

android - web服务返回10000行数据,如何处理