如何测试外部应用程序正确运行?

时间:2017-04-25 06:29:32

标签: android android-espresso

目标是测试外部应用运行意图。当此测试用例通过所有下一个测试用例失败时,因为外部应用程序在测试用例完成后没有关闭。我的测试看起来像:

public class MarketIntentCase {

private ActivityTestRule<SomeActivity> activityTestRule = new ActivityTestRule<>(SomeActivity.class, true, false);   

@Rule
public RuleChain ruleChain = RuleChain.emptyRuleChain()
        .around(activityTestRule); 

    @Before
    public void launchActivity() {
        Intent intent = new Intent();
        activityTestRule.launchActivity(intent);
    }

public void shouldShowGooglePlay() {
        Intents.init();
        Intents.intended(hasData(Uri.parse(Constants.MARKET_URL)));
        Intents.intended(hasAction(Intent.ACTION_VIEW));
        Intents.release();
    }
}

请告诉我如何正确测试这种行为。谢谢!

1 个答案:

答案 0 :(得分:0)

在运行Espresso测试时,没有解决方案可以杀死Activity(外部或测试中的应用)。也许如果你结合使用Espresso和UI自动机(https://developer.android.com/training/testing/ui-testing/uiautomator-testing.html),它应该可以使用,来源:http://alexzh.com/tutorials/android-testing-espresso-uiautomator-together/

相关问题