简体   繁体   中英

How to create appium TestSuite in Android Studio

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.

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> 

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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