问题
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:
- Create a new folder under your project.
- Create a xml file
- 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