How to create appium TestSuite in Android Studio

只谈情不闲聊 提交于 2019-12-12 01:48:43

问题


I have created test stub using Appium in android studio. Now I want to create test suite so that I can manage my test cases. Could anyone help me how to create test suite for appium test cases?

My AppiumTest.java contains

public class AndroidAppiumTest {

    private AppiumDriver wd;

    @Before
    public void setUp() throws Exception {
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("deviceName","Android");
        capabilities.setCapability("appium-version", "1.0");
        capabilities.setCapability("platformName", "Android");
        capabilities.setCapability("platformVersion", "4.4");
        capabilities.setCapability("appPackage", "com.appundertest");
        capabilities.setCapability("appActivity", "MainActivity");
        wd = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    }

    @After
    public void tearDown() throws Exception {
        wd.quit();
    }

    @Test
    public void testCase(){ 
     // Test code for feature 1
     // Test code for feature 2
     } `

How can I create separate test.java file for each feature and a test suite to manage all test cases altogether -

    `TestSuite suite = new TestSuite();
       suite.countTestCases();
       suite.addTestSuite(AndroidAppiumTest.class);
       suite.addTestSuite(NetworkCheck.class);
       return suite;

Could anyone please tell me how to create such test framework? I am using android studio.


回答1:


Few steps to follow:

  1. Create a new folder under your project.
  2. Create a xml file
  3. mention all your test cases in the xml file. This way you can run all your test cases through xml file.
<suite name="Group" verbose="1"
    thread-count="10">
    <test name="TestApp" thread-count="10">
        <classes>
            <class name="PackageName"."ClassName" />
        </classes>
    </test>
</suite> 



回答2:


You can use below code for creating Test Suit

import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;

    @RunWith(Suite.class)
@SuiteClasses({
                FirstTestClass.class,
                SecondTestClass.class,
                SecondTestClass.class })
public class AllTests {

}   

This code is taken from example on THIS PAGE Regards,

Anuja



来源:https://stackoverflow.com/questions/28899940/how-to-create-appium-testsuite-in-android-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!