From 46c2cce37c84fa901c40c746cdfe9b61d4354eee Mon Sep 17 00:00:00 2001 From: Oowisho <145649282+Oowisho@users.noreply.github.com> Date: Fri, 13 Jun 2025 00:37:20 +0800 Subject: [PATCH] src --- src/ExampleInstrumentedTest.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 src/ExampleInstrumentedTest.java diff --git a/src/ExampleInstrumentedTest.java b/src/ExampleInstrumentedTest.java new file mode 100644 index 0000000..ea1502d --- /dev/null +++ b/src/ExampleInstrumentedTest.java @@ -0,0 +1,32 @@ +package net.micode.notes; + +import android.content.Context; + +import androidx.test.platform.app.InstrumentationRegistry; +import androidx.test.ext.junit.runners.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * 仪器化测试类,运行在真实Android设备或模拟器上 + * 用于验证应用的基本配置是否正确 + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + /** + * 测试应用上下文的包名是否正确 + * 这是一个基本的健全性检查,确保测试环境能够正确加载应用 + */ + @Test + public void useAppContext() { + // 获取被测应用的上下文 + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); + + // 验证应用包名是否符合预期 + // 包名是应用的唯一标识符,通常在build.gradle文件中定义 + assertEquals("net.micode.notes", appContext.getPackageName()); + } +} \ No newline at end of file