Robotium。在套件的测试,每个测试旁边是受previous测试 [英] Robotium. In the suite of tests each next test is affected by the previous test

查看:102
本文介绍了Robotium。在套件的测试,每个测试旁边是受previous测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个UI测试。当我运行一个测试,一切正常。但是,如果我运行批处理其中(为CI构建的一部分)的测试失败,因为去第一测试改变应用程序的状态,并且下一个测试由这些变化的影响。 (由于应用程序不被杀死)。

I have multiple UI tests. When I run a single test, everything is OK. But if I run a batch of them (as a part of CI build) test fail, because tests that go first change the state of the application, and the next tests are affected by those changes. (Since the app is not getting killed).

我试过 getActivity()。完成()拆解()。结果
试图 solo.finalize()这的确实际上是相同的。

I tried getActivity().finish() in tearDown().
Tried solo.finalize() which does the same actually.

有没有办法让每个测试运行的开始一个新的应用程序? (使用Robotium)。结果
而有没有办法以编程方式杀死在试验结束时,应用程序?结果
我使用 ActivityInstrumentationTestCase2 与Robotium

Is there a way to have a fresh app at the beginning of each test run? (Using Robotium).
And is there a way to programmatically kill the app at the end of a test?
I'm using ActivityInstrumentationTestCase2 with Robotium

推荐答案

为什么不加入杀人的应用程序,这取决于你正在测试的具体应用即席方式?
例如,根据您的应用程序活动的深度,的preSS回3次的或类似的可够好东西。

Why not adding an adhoc way of "killing" the app, depending on the specific app you're testing? For example, depending on your application activity depth, "press back 3 times" or something similar could be good enough.

您可以添加在您的测试超类的拆卸的方法,所以,它的每个测试后跑去。

You could add that in the tearDown method of your tests superclass, so that it's ran after each of your tests.

您应该想想你的 Robotium 测试不是一般的单元测试(他们不!),但作为用户的情况下,接受检验。所以,如果你想关闭该应用程序,在做这些测试正是你所期待的用户做关闭应用程序。

You should think about your Robotium tests not as normal unit-tests (they're not!), but as user-cases, acceptance-tests. So if you want to close the app, do in these tests exactly what you would expect the user to do to close the app.

这篇关于Robotium。在套件的测试,每个测试旁边是受previous测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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