Android的工作室表示,"空测试套件"对于AndroidTestCase [英] Android studio says "Empty Test Suite" for AndroidTestCase

查看:573
本文介绍了Android的工作室表示,"空测试套件"对于AndroidTestCase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建一个扩展AndroidTestCase一个例子测试用例。当我运行测试的情况下,
它出现了错误,说

 运行测试
测试运行startedTest运行失败:
由于仪器运行失败'了java.lang.RuntimeException
空测试套件。

测试用例

 进口android.test.AndroidTestCase;
进口android.test.suitebuilder.annotation.SmallTest;引入静态org.junit.Assert.assertEquals;进口org.junit.AfterClass;
进口org.junit.BeforeClass;
进口org.junit.Test;进口java.lang.Exception的;
进口java.lang.Override;公共类DateFormatTest扩展AndroidTestCase {    @覆盖
    保护无效设置()抛出异常{
        super.setUp();
    }    @覆盖
    保护无效拆解()抛出异常{
        super.tearDown();
    }    公共DateFormatTest(){
        超(DateFormatTest.class);
    }
    @SmallTest
    公共无效testMultiply(){        的assertEquals(10×5必须为50,50,10 * 5);
    }
}


解决方案

我从Android Studio中运行测试时得到这个错误。原来,我已经把我的测试案例在错误的文件夹中。当运行摇篮/ Android的工作室,所有的Andr​​oid测试应该在文件夹中的src / instrumentTest / JAVA

编辑:在摇篮插件0.9或更高版本的文件夹的正确名称是 androidTest 。 (<一href=\"http://tools.android.com/tech-docs/new-build-system/migrating_to_09\">http://tools.android.com/tech-docs/new-build-system/migrating_to_09)

I have created an example test case that extends AndroidTestCase. When I run the test case, it errors out by saying

Running tests
Test running startedTest running failed: 
Instrumentation run failed due to 'java.lang.RuntimeException'
Empty test suite.

The test case

import android.test.AndroidTestCase;
import android.test.suitebuilder.annotation.SmallTest;

import static org.junit.Assert.assertEquals;

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

import java.lang.Exception;
import java.lang.Override;

public class DateFormatTest extends AndroidTestCase{

    @Override
    protected void setUp() throws Exception {
        super.setUp();
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
    }

    public DateFormatTest(){
        super(DateFormatTest.class);
    }


    @SmallTest
    public void testMultiply() {

        assertEquals("10 x 5 must be 50", 50, 10*5);
    }
}

解决方案

I got this error when running tests from Android Studio. Turned out I had placed my test cases in the wrong folder. When running Gradle/Android Studio, all Android tests should be in the folder src/instrumentTest/java.

Edit: In Gradle plugin version 0.9 or later the correct name of the folder is androidTest. (http://tools.android.com/tech-docs/new-build-system/migrating_to_09)

这篇关于Android的工作室表示,&QUOT;空测试套件&QUOT;对于AndroidTestCase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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