简体   繁体   English

getStartedActivityIntent使用ActivityUnitTestCase在单元测试用例中返回null

[英]getStartedActivityIntent returns null in Unit Test Case using ActivityUnitTestCase

I am writing Unit test case to test an Activity. 我正在编写单元测试用例来测试一个Activity。 Extending ActivityUnitTestCase class. 扩展ActivityUnitTestCase类。 Launching basic intent first. 首先启动基本意图。 Then using TouchUtils, Performing intended actions. 然后使用TouchUtils,执行预期的操作。 there is startActivity() call in my action. 我的动作中有startActivity()调用。 While debugging code i am able to see, the activity is started. 在我能够看到的调试代码时,活动已启动。 but when in testcase using getStartedActivityIntent it returns null. 但是在使用getStartedActivityIntent的 testcase中,它返回null。 What i have to do? 我该怎么办?

I would advise you to use "Functional Tests" with an ActivityMonitor: 我建议你在ActivityMonitor中使用“Functional Tests”:

http://developer.android.com/training/activity-testing/activity-functional-testing.html http://developer.android.com/training/activity-testing/activity-functional-testing.html

There starting an activity and verifying it works for me. 开始活动并验证它对我有用。 With getStartedActivityIntent() using in an ActivityUnitTestCase also does not work for me. 使用ActivityUnitTestCase中的getStartedActivityIntent()也不适用于我。

ActivityUnitTestCase is going to be deprecated. ActivityUnitTestCase将被弃用。 Don't use it anymore. 不要再使用它了。 Refer to the following issue 请参阅以下问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM