android JUnit测试未运行

主要 :

问题不是测试失败,而是根本根本没有运行。也就是说,控制台告诉我它们正在运行,但是我绝对看不到它们的任何结果。

请注意,我已经“记得”使用@Test注释方法

这是测试类的代码:

package module.jakway.JournalEntry.test;


import module.jakway.JournalEntry.Module_JournalEntry;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public class MainTest extends android.test.ActivityInstrumentationTestCase2<Module_JournalEntry>
{

    public MainTest(Class activityClass) {
        super("module.jakway.JournalEntry", Module_JournalEntry.class);
        // TODO Auto-generated constructor stub
    }

    @BeforeClass
    public static void setUpBeforeClass() throws Exception {
    }

    @AfterClass
    public static void tearDownAfterClass() throws Exception {
    }

    @Before
    public void setUp() throws Exception {
        super.setUp();

        Module_JournalEntry journalentry = getActivity();

        assertTrue(true);
    }

    @After
    public void tearDown() throws Exception {
    }

    @Test
    public void myTestCase()
    {
        assertTrue(false);
    }

}

我正在测试的项目的名称为Module_JournalEntry,其包为module.jakway.JournalEntry和Activity Module_JournalEntry.java

这是控制台输出:

[2011-02-04 20:37:10 - Module_JournalEntryTest] Performing android.test.InstrumentationTestRunner JUnit launch
[2011-02-04 20:37:10 - Module_JournalEntryTest] Automatic Target Mode: using existing emulator 'emulator-5554' running compatible AVD 'my2.3Emulator'
[2011-02-04 20:37:12 - Module_JournalEntryTest] Application already deployed. No need to reinstall.
[2011-02-04 20:37:12 - Module_JournalEntryTest] Project dependency found, installing: Module_JournalEntry
[2011-02-04 20:37:14 - Module_JournalEntry] Application already deployed. No need to reinstall.
[2011-02-04 20:37:14 - Module_JournalEntryTest] Launching instrumentation android.test.InstrumentationTestRunner on device emulator-5554
[2011-02-04 20:37:14 - Module_JournalEntryTest] Collecting test information
[2011-02-04 20:37:17 - Module_JournalEntryTest] Sending test information to Eclipse
[2011-02-04 20:37:17 - Module_JournalEntryTest] Running tests...
[2011-02-04 20:37:19 - Module_JournalEntryTest] Test run finished

和logcat输出:

02-04 20:37:10.266: DEBUG/AndroidRuntime(524): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-04 20:37:10.266: DEBUG/AndroidRuntime(524): CheckJNI is ON
02-04 20:37:11.236: DEBUG/AndroidRuntime(524): Calling main entry com.android.commands.pm.Pm
02-04 20:37:11.316: DEBUG/AndroidRuntime(524): Shutting down VM
02-04 20:37:11.336: INFO/AndroidRuntime(524): NOTE: attach of thread 'Binder Thread #3' failed
02-04 20:37:11.346: DEBUG/dalvikvm(524): GC_CONCURRENT freed 102K, 71% free 297K/1024K, external 0K/0K, paused 3ms+8ms
02-04 20:37:11.346: DEBUG/jdwp(524): Got wake-up signal, bailing out of select
02-04 20:37:11.346: DEBUG/dalvikvm(524): Debugger has detached; object registry had 1 entries
02-04 20:37:12.316: DEBUG/AndroidRuntime(534): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-04 20:37:12.316: DEBUG/AndroidRuntime(534): CheckJNI is ON
02-04 20:37:13.136: DEBUG/AndroidRuntime(534): Calling main entry com.android.commands.pm.Pm
02-04 20:37:13.186: DEBUG/AndroidRuntime(534): Shutting down VM
02-04 20:37:13.216: INFO/AndroidRuntime(534): NOTE: attach of thread 'Binder Thread #3' failed
02-04 20:37:13.216: DEBUG/dalvikvm(534): GC_CONCURRENT freed 102K, 71% free 297K/1024K, external 0K/0K, paused 1ms+1ms
02-04 20:37:13.216: DEBUG/dalvikvm(534): Debugger has detached; object registry had 1 entries
02-04 20:37:14.256: DEBUG/AndroidRuntime(544): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-04 20:37:14.256: DEBUG/AndroidRuntime(544): CheckJNI is ON
02-04 20:37:15.126: DEBUG/AndroidRuntime(544): Calling main entry com.android.commands.am.Am
02-04 20:37:15.176: INFO/ActivityManager(75): Force stopping package module.jakway.JournalEntry uid=10035
02-04 20:37:15.206: INFO/ActivityManager(75): Start proc module.jakway.JournalEntry for added application module.jakway.JournalEntry: pid=552 uid=10035 gids={1015}
02-04 20:37:15.876: WARN/TestGrouping(552): Invalid Package: '' could not be found or has no tests
02-04 20:37:15.976: INFO/ActivityManager(75): Force stopping package module.jakway.JournalEntry uid=10035
02-04 20:37:15.976: INFO/Process(75): Sending signal. PID: 552 SIG: 9
02-04 20:37:15.986: DEBUG/AndroidRuntime(544): Shutting down VM
02-04 20:37:16.016: DEBUG/dalvikvm(544): GC_CONCURRENT freed 103K, 71% free 299K/1024K, external 0K/0K, paused 1ms+4ms
02-04 20:37:16.036: INFO/AndroidRuntime(544): NOTE: attach of thread 'Binder Thread #3' failed
02-04 20:37:16.046: DEBUG/jdwp(544): Got wake-up signal, bailing out of select
02-04 20:37:16.046: DEBUG/dalvikvm(544): Debugger has detached; object registry had 1 entries
02-04 20:37:16.656: DEBUG/AndroidRuntime(563): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<<
02-04 20:37:16.665: DEBUG/AndroidRuntime(563): CheckJNI is ON
02-04 20:37:17.646: DEBUG/AndroidRuntime(563): Calling main entry com.android.commands.am.Am
02-04 20:37:17.716: INFO/ActivityManager(75): Force stopping package module.jakway.JournalEntry uid=10035
02-04 20:37:17.746: INFO/ActivityManager(75): Start proc module.jakway.JournalEntry for added application module.jakway.JournalEntry: pid=572 uid=10035 gids={1015}
02-04 20:37:18.606: WARN/TestGrouping(572): Invalid Package: '' could not be found or has no tests
02-04 20:37:18.826: INFO/ActivityManager(75): Force stopping package module.jakway.JournalEntry uid=10035
02-04 20:37:18.826: INFO/Process(75): Sending signal. PID: 572 SIG: 9
02-04 20:37:18.846: DEBUG/AndroidRuntime(563): Shutting down VM
02-04 20:37:18.906: INFO/AndroidRuntime(563): NOTE: attach of thread 'Binder Thread #4' failed
02-04 20:37:18.916: DEBUG/dalvikvm(563): GC_CONCURRENT freed 103K, 71% free 298K/1024K, external 0K/0K, paused 2ms+28ms
02-04 20:37:18.916: DEBUG/jdwp(563): Got wake-up signal, bailing out of select
02-04 20:37:18.926: DEBUG/dalvikvm(563): Debugger has detached; object registry had 1 entries

非常感谢!

迭戈·托雷斯·米兰:

Android的测试框架基于JUnit 3,该框架不使用批注,但反射和测试方法名称应包含测试前缀。

移至JUnit 3并从Eclipse Run As -> Android JUnit Testam instrument从命令行运行测试

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

机器人测试未运行(Android)

如何在Android Studio中运行普通的旧JUnit测试

由于歧义参数异常,Android工具测试未运行

无法在Android JUnit 4已测试的测试中启动未绑定服务

CircleCI测试摘要中未显示Android Junit4测试

在Android Eclipse JUnit项目中的各个类上运行原始JUnit测试

使用Ant运行Android JUnit测试:ClassNotFoundException:org.junit.Test

JUnit测试Android NullPointerException

JUnit测试Android NullPointerException

尝试运行琐碎的Android JUnit测试。得到:“测试运行失败:没有测试结果”我缺少什么?

为android gradle junit测试运行获取XML / HTML测试结果

Maven 2未运行Junit 4测试

Jenkins Maven构建未运行JUnit测试

Android RxJava 2 JUnit测试-未模拟android.os.Looper中的getMainLooper RuntimeException

从命令行运行JUnit Test:Android项目中的非Android测试

在Android Studio中的Android项目中运行快速JUnit测试的最佳方法

如何在 Android Studio 北极狐上运行 JUnit 测试 | 2020.3.1?

如何在Android Studio 1.1中运行简单的JUnit4测试?

在Eclipse Android项目中无法运行JUnit 4测试用例

使用基于Gradle的配置时在Android Studio(IntelliJ)上运行简单的JUnit测试

Android Studio未运行

JUnit 5测试未触发且测试运行程序中未显示测试

如何在设备或模拟器上未运行Android的单元测试?

Android:测试广告未显示

Android Studio 1.2,运行测试

Travis-CI和Android JUnit测试

Android:JUnit + Mockito,测试回调?

使用JUNIT进行Android文件操作测试

在Android JUnit测试中加载本机库