有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

运行包含5个测试的包后会出现java 0 test classes found消息

运行包含5个测试的包后,将显示“找到0个测试类”消息

尝试运行包含5个测试的包时出现“未找到任何测试”错误。(TestNG)

0 test classes found in package 'smoketest'

Process finished with exit code 255
Empty test suite.
基础包运行良好。但是“smoketest”返回找到的0个测试类

packages

modules

package smoketest;


import com.pageobjects.*;
import config.AndroidGestures;
import config.DesiredCapabilitiesSetup;
import config.LogIn;
import io.appium.java_client.安卓.AndroidDriver;
import io.appium.java_client.安卓.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();
    }
}

格雷德尔:

group 'ao-core-安卓'
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.安卓.tools.build:gradle:1.1.0'
    compile fileTree(dir: 'externalLibs', include: ['*.jar'])
    compile files('./lib-test-tools-1.4.0.jar')
}

TestNG。xml

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Smoke Test">
    <listeners>
        <listener class-name="config.CustomLogger" />
    </listeners>
    <test name="SmokeTest">
        <packages>
            <package name="smoketest"/>
        </packages>
    </test>
</suite>

共 (1) 个答案

  1. # 1 楼答案

    <test name="Email">
        <classes>
        <class name="<package name>.<class name>"/> 
        </classes>
    </test>
    

    类似于上面的事情,我们需要在测试中包含类,然后只有测试套件才会执行它