【问题标题】:Unit testing: Entry name 'res/layout/test_toolbar.xml' collided单元测试:条目名称“res/layout/test_toolbar.xml”发生冲突
【发布时间】:2020-06-11 04:57:31
【问题描述】:

我尝试做一些包含在 Android Studio 项目中的单元测试示例,例如 ExampleInstrumentedTestExampleUnitTest,所以结果是:

条目名称“res/layout/test_toolbar.xml”发生冲突

我在谷歌上到处搜索,但没有解决这个具体问题,所以任何帮助将不胜感激

这里是基本单元测试示例的来源:

ExampleUnitTest

 * Example local unit test, which will execute on the development machine (host).
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
public class ExampleUnitTest {
    @Test
    public void addition_isCorrect() {
        assertEquals(4, 2 + 2);
    }}

ExampleInstrumentedTest

 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getInstrumentation().getContext();

        assertEquals("com.example.abder.emarque", appContext.getPackageName());
    }}

【问题讨论】:

标签: java android unit-testing android-debug test-coverage


【解决方案1】:

我刚刚做了以下,它解决了我的问题。

  1. 使缓存无效并重新启动(文件 -> 使缓存无效/重新启动)
  2. 清理项目(构建 -> 清理项目)

【讨论】:

    猜你喜欢
    • 2020-06-09
    • 2021-06-03
    • 2021-01-17
    • 2021-04-16
    • 1970-01-01
    • 2018-01-21
    • 1970-01-01
    • 1970-01-01
    • 2016-05-15
    相关资源
    最近更新 更多