在运行包含5个测试的包后,会出现0个测试类消息。
尝试运行包含5个测试的包时,出现“未找到测试”错误。 (TestNG)xampp\php\php.ini
基础包运行正常。但“smoketest”返回0个测试类。
0 test classes found in package 'smoketest'
Process finished with exit code 255
Empty test suite.
Gradle:
package smoketest;
import com.pageobjects.*;
import config.AndroidGestures;
import config.DesiredCapabilitiesSetup;
import config.LogIn;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.testng.asserts.SoftAssert;
public class CardManagementTest {
private AndroidDriver<AndroidElement> driver;
private AOWebClient aoWeb;
@SuppressWarnings("unused")
public CardManagementTest(AndroidDriver<AndroidElement> driver, AOWebClient aoWeb) {
this.driver = driver;
this.aoWeb = aoWeb;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
}
@SuppressWarnings("unused")
public CardManagementTest() {
}
@BeforeClass
public void setUp() throws Exception {
driver = DesiredCapabilitiesSetup.startAppiumServer();
}
@Test
public void cardManagementTest() throws InterruptedException {
SoftAssert softAssert = new SoftAssert();
AOWebClient aoWebClient = DesiredCapabilitiesSetup.getAOWeb();
HamburgerMenuList ham = new HamburgerMenuList(driver,aoWeb);
ProfileInfoScreen profile = new ProfileInfoScreen(driver);
CardManagementScreen card = new CardManagementScreen(driver, aoWeb);
LogIn logIn = new LogIn(driver, aoWebClient);
HeaderMenu header = new HeaderMenu(driver, aoWeb);
AndroidGestures gesture = new AndroidGestures(driver);
String month = "Aug";
String year = "2020";
String cardNumber = "4444333322221111";
String cvv = "123";
String expectedCardLastDigits = cardNumber.substring(12);
logIn.loginWithYourCredentials("c1@mailinator.com", "testtest");
header.clickHamburgerButton();
ham.waitForHamMenuScreentoLoad();
ham.accountButtonClick();
profile.waitForProfileScreenToLoad();
profile.cardManagementClick();
card.waitForCardManagementScreenToLoad();
softAssert.assertTrue(card.noSavedCardLabelAppear(), "No saved Card Label Does Not Appear");
card.setAddCardButtonClick();
card.cardNumberInput(cardNumber);
card.cardExpClick();
card.monthPickerWheel.click();
card.selectAugustMonth();
card.yearPickerWheel.click();
card.selectYear2020();
card.dateSubmitButton.click();
card.cardCVVClick();
card.cardCVVInput(cvv);
card.cardSaveClick();
card.waitForCardManagementScreenToLoad();
softAssert.assertEquals(card.creditCardGetLast4Digits(), expectedCardLastDigits, "Actual Credit Card and Expected Credit card numbers are not the same");
//Assertion that Credit Card was added 4 last digits
card.deleteCreditCardButtonClick();
//Assertion that "Delete this saved card" message appear
softAssert.assertTrue(card.confirmDeleteLabelAppear(), "Delete confirmation screen did not appear");
card.cancelDeleteCardButtonClick();
softAssert.assertEquals(card.creditCardGetLast4Digits(), expectedCardLastDigits, "Actual Credit Card and Expected Credit card numbers are not the same");
card.deleteCreditCardButtonClick();
card.confirmdeleteCardButtonClick();
card.waitForNoSavedCardLabelLoad();
softAssert.assertTrue(card.noSavedCardLabelAppear(), "No saved Card Label Does Not Appear");
header.backButtonClick();
profile.waitForProfileScreenToLoad();
softAssert.assertTrue(profile.profileScreenAppear(), "Profile View Page Does Not Appear");
softAssert.assertAll();
}
@AfterClass
public void tearDown() throws Exception {
driver.closeApp();
driver.quit();
}
}
的testng.xml
group 'ao-core-android'
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.5
test {
useTestNG {
suites 'testng.xml'
}
}
repositories {
mavenCentral()
jcenter()
}
dependencies {
//testCompile group: 'junit', name: 'junit', version: '4.11'
//compile 'org.testng:testng:6.9.10'
compile 'org.testng:testng:6.9.12'
//compile 'org.testng:testng:6.9.10'
compile 'io.appium:java-client:4.0.0'
compile 'org.seleniumhq.selenium:selenium-java:2.53.1'
compile 'com.android.tools.build:gradle:1.1.0'
compile fileTree(dir: 'externalLibs', include: ['*.jar'])
compile files('./lib-test-tools-1.4.0.jar')
}
答案 0 :(得分:0)
<test name="Email">
<classes>
<class name="<package name>.<class name>"/>
</classes>
</test>
与上述类似,我们需要在测试中使用类,然后只有测试套件会执行它。