首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >机器人中的测试套件问题

机器人中的测试套件问题
EN

Stack Overflow用户
提问于 2011-11-21 15:49:59
回答 3查看 755关注 0票数 0

我有一个包含大约20个方法(测试用例)的测试用例文件,它扩展了ActivityInstrumentationTestCase2。我需要编写一个套件,它将只调用选定的测试用例方法,我知道在junit中有一个方法接受要执行的方法。

代码语言:javascript
运行
复制
    suite.addTest( new AllTestCases("testcase1"));

在android robotium中有没有类似的方法?如果是,请帮我解决这个问题。谢谢。

EN

回答 3

Stack Overflow用户

发布于 2012-05-08 08:03:02

您不能进行像new AllTestCases("testcase1");这样的调用,因为所有与Android相关的测试类都继承自AndroidTestCaseInstrumentationTestCase,并且这两个类都没有公开以字符串作为参数的构造函数。

您可以看看android.test.suitebuilder.TestSuiteBuilder,但即使这个类不允许运行单独的测试方法,它也接受包级别的测试。

你可以通过使用@SmallTest@MediumTest@LargeTest等安卓测试注解来实现你的目标。这些注解允许你使用下面的命令只针对指定的带注解的方法:

代码语言:javascript
运行
复制
adb shell am instrument -w -e size <small|medium|large> com.youproject.test/android.test.InstrumentationTestRunner

最后,可以直接从eclipse中针对各个测试方法或类进行测试。

票数 1
EN

Stack Overflow用户

发布于 2014-08-25 21:56:56

要直接从命令行运行单个测试用例:

adb shell am instrument -w -e class <Test-Class-With-Package-Name>#<Test-Method-Name> <Package-Name-Of-Test-App>/<Instrumentation-Name-Defined-In-Manifest>

示例:

adb shell am instrument -w -e class com.myapp.test.ActivityFragmentTest#testLogin com.myapp.test/android.test.InstrumentationTestRunner

票数 1
EN

Stack Overflow用户

发布于 2012-06-01 08:43:12

您可以使用"adb shell am instrument“命令的"-e”参数以编程方式运行各个测试用例。例如,对于'com.foo.bar.FooTest‘中的方法'testFoo()’,您可以运行:

com.foo.bar.test/android.test.InstrumentationTestRunner shell am instrument -w \ -e "class com.foo.bar.FooTest#testFoo“\ adb shell am instrument

http://developer.android.com/guide/developing/testing/testing_otheride.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8208713

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档