Android Studio 中的重复类错误 [英] Duplicate class error in Android Studio

查看:50
本文介绍了Android Studio 中的重复类错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Android Studio.

I'm using Android Studio.

我的代码库位于 app/src/main/java,单元测试位于 app/src/test/java 和插桩测试 app/src/androidTest/java.

My code base is located in app/src/main/java, unit tests in app/src/test/java and instrumented tests in app/src/androidTest/java.

对于一个名为 Foo 的类,我可以创建一个单元测试 FooTest 但是当我创建一个插装测试 FooTest 我得到一个重复的类错误.

For a class named Foo I can create a unit test FooTest but as I create an instrumented test FooTest I get a duplicate class error.

有什么办法可以解决这个问题,还是应该更改一个测试类?

Is there any way I can resolve this, or should I change one of test classes?

推荐答案

奇怪的是,如果您遵循 MVC(或它的众多变体之一),您需要在检测和普通单元测试下测试相同的类您无需担心绝大多数测试的仪器.我从未经历过这种情况,但我认为是的 - 您需要保持测试名称不同.

It is odd that you need the same class tested under instrumented and vanilla unit tests since if you've followed MVC (or one of its many, many variations) you shouldn't need to worry about instrumentation for the vast majority of your testing. I've never experienced this but I think that yes - you would need to keep the test names distinct.

这篇关于Android Studio 中的重复类错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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