【发布时间】:2020-06-11 04:57:31
【问题描述】:
我尝试做一些包含在 Android Studio 项目中的单元测试示例,例如 ExampleInstrumentedTest 和 ExampleUnitTest,所以结果是:
条目名称“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());
}}
【问题讨论】:
-
在此处查看类似错误和可能的解决方案:stackoverflow.com/a/68501093/1633493
标签: java android unit-testing android-debug test-coverage