如何在一个特定的顺序运行robotium测试? [英] How to run robotium tests in a specific order?

查看:303
本文介绍了如何在一个特定的顺序运行robotium测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有有一个这样的TestClass robotium testproject。测试类包含了所有的测试方法。现在,当我运行测试类,测试方法是按照字母顺序运行。由于我有测试方法之间的一些依赖(我知道这是不是preferred做法)我想要的测试方法,在一个特定的顺序运行。我有依赖的原因是,它允许较少code写入并使得整个测试类运行得更快。有没有什么办法,以特定的顺序运行测试方法是什么?

I have this robotium testproject which has one testclass. The test class contains all the test methods. Right now when I run the test class, the test methods are run in alphabetical order. Since I have some dependencies between the test methods(i know this is not the preferred practice) I want the test methods to run in a specific order. The reason I am having dependencies is that, it allows for less code to be written and makes the whole test class to run faster. Is there any way to run the test methods in a specific order?

推荐答案

创建包含testsuit秩序的类。对于例如:

Create an Class which contains the order of testsuit. For eg:

package com.android.test; 

import junit.framework.TestSuite;
import android.app.Activity;
import android.test.ActivityInstrumentationTestCase2;

public class AllTests extends  ActivityInstrumentationTestCase2<Activity> {



    public AllTests(Class<Activity> activityClass) {
        super(activityClass);
    }

    public static TestSuite suite() {
        TestSuite t = new TestSuite();
        t.addTestSuite(SplashScreenTest.class);
        t.addTestSuite(MainLoginScreenTest.class);
        t.addTestSuite(EmailSignUpScreenTest.class);
        t.addTestSuite(EmailVerificationTest.class);
        t.addTestSuite(EmailLoginScreenTest.class);

        return t; 
    }

    @Override
    public void setUp() throws Exception {

    }


    @Override
    public void tearDown() throws Exception {
    }

}

通过这种方式,您可以设置您的robotium的执行顺序
 测试服。有关完整的教程检查这个 链接

By this way you can set the order of execution of your robotium test suit. For complete tutorial check this link

这篇关于如何在一个特定的顺序运行robotium测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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