簡體   English   中英

無法使用 testng 配置運行我的測試 class

[英]Can't run my test class with testng config

我對自己運行測試類有疑問。 將我的 IntelliJ IDEA 從版本 2018 更新到 2020 后,我無法使用 testNG 自行運行測試,它通過 Gradle 運行並且不起作用。

我的 build.gradle

plugins {
    id 'io.qameta.allure' version "2.4"
    id "net.ltgt.apt" version "0.15"
}


allure {
    version = '2.4.1'
    autoconfigure = true
    aspectjweaver = true
    allureJavaVersion = '2.0-BETA9'
}


apply plugin: 'java-library'
apply plugin: "io.qameta.allure"


repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.1'
    implementation 'org.testng:testng:6.11'
    implementation 'org.seleniumhq.selenium:selenium-java:3.6.0'
    implementation 'org.hamcrest:java-hamcrest:2.0.0.0'
    implementation 'com.beust:jcommander:1.72'
    implementation 'com.thoughtworks.xstream:xstream:1.4.8'
    implementation 'com.google.code.gson:gson:2.8.2'
    implementation 'ch.qos.logback:logback-classic:1.1.5'
    implementation 'org.apache.poi:poi:3.17'
    implementation 'org.apache.maven.plugins:maven-compiler-plugin:3.7.0'
    implementation 'ru.yandex.qatools.ashot:ashot:1.5.4'
    implementation 'io.rest-assured:rest-assured:4.2.0'
    implementation 'org.projectlombok:lombok:1.18.16'
    compileOnly 'org.projectlombok:lombok:1.18.16'
    annotationProcessor 'org.projectlombok:lombok:1.18.16'
    testCompileOnly 'org.projectlombok:lombok:1.18.16'
    testAnnotationProcessor 'org.projectlombok:lombok:1.18.16'


//    DB
    implementation("org.hibernate:hibernate-core:5.3.10.Final")
    implementation("mysql:mysql-connector-java:8.0.16")


    /*def excludeLog = {exclude group: 'ch.qos.logback:logback-core', 'ch.qos.logback:logback-classic'}
    compile 'net.sourceforge.tess4j:tess4j:4.2.2', excludeLog*/
    /*def excludeLog = {exclude group: 'ch.qos.logback:logback-core', 'ch.qos.logback:logback-classic'}*/
    implementation 'net.sourceforge.tess4j:tess4j:4.3.1'
    implementation group: 'org.springframework', name: 'spring-web', version: '3.0.2.RELEASE'
    implementation group: 'org.postgresql', name: 'postgresql', version: '42.2.5'


    //Gmail
    implementation 'com.google.api-client:google-api-client:1.23.0'
    implementation 'com.google.oauth-client:google-oauth-client-jetty:1.23.0'
    implementation 'com.google.apis:google-api-services-gmail:v1-rev83-1.23.0'

    //ftp client
    implementation group: 'commons-net', name: 'commons-net', version: '3.6'
}

task testLttTestServer(type: Test) {
    useTestNG() {
        suites 'src/test/resources/testNG/testng-ltt-test-regression.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task testLttProdServer(type: Test) {
    useTestNG() {
        suites 'src/test/resources/testNG/testng-ltt-prod-regression.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task testKparserProdServer(type: Test) {
    useTestNG() {
        suites 'src/test/resources/testNG/testng-kparser-prod-regression.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task testSeo(type: Test) {
    if (project.hasProperty('jsonName')) {
        systemProperty 'jsonName', "${jsonName}"
    }
    useTestNG() {
        suites 'src/test/resources/testNG/testng-SeoUtil-test.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task testSitecheckerDB(type: Test) {
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsalt', "${pswsalt}"
    }
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsk', "${pswsk}"
    }
    useTestNG() {
        suites 'src/test/resources/testNG/dbTests/testng-sitechecker-position-test.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task testSitecheckerNotifications(type: Test) {
    useTestNG() {
        suites 'src/test/resources/testNG/testng-sitechecker-notifications.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task testCopywritely(type: Test) {
    useTestNG() {
        suites 'src/test/resources/testNG/testng-copywritely-regression.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task testSitecheckerNewUI(type: Test) {
    useTestNG() {
        suites 'src/test/resources/testNG/SCnew.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task crawlerTest(type: Test) {
    useTestNG() {
        suites 'src/test/resources/testNG/sitechecker-crawling-test.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task alxLocalhostTest(type: Test) {
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsalt', "${pswsalt}"
    }
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsk', "${pswsk}"
    }
    useTestNG() {
        suites 'src/test/resources/testNG/alx-test.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task noMonitoringTest(type: Test) {
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsalt', "${pswsalt}"
    }
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsk', "${pswsk}"
    }
    useTestNG() {
        suites 'src/test/resources/testNG/dbTests/noMonitoringTest.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task inProgressDomainsTest(type: Test) {
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsalt', "${pswsalt}"
    }
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsk', "${pswsk}"
    }
    useTestNG() {
        suites 'src/test/resources/testNG/dbTests/testng-sitechecker-inProgressDomain-test.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

task userWorkFlowTest(type: Test) {
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsalt', "${pswsalt}"
    }
    if (project.hasProperty('pswsalt')) {
        systemProperty 'pswsk', "${pswsk}"
    }
    useTestNG() {
        suites 'src/test/resources/testNG/testng-sitechecker-prod-UserWorkFlowtest.xml'
        useDefaultListeners = true
    }
    reports.html.enabled = false
}

我仍然可以使用 testNG 毫無問題地運行任何 xml 文件,但無法理解單個配置 class 發生了什么。

https://prnt.sc/1129yr4

該問題已通過將 gradle 運行配置中的值“運行測試”從“gradle”更改為“intelliJ”來解決

https://prnt.sc/112b4el

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM