不能 运行 我的测试 class 使用 testng 配置
Can't run my test class with testng config
我对 运行ning 测试 classes 本身有疑问。将我的 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.
发生了什么
问题已通过将 gradle 运行 配置中的值 'run tests' 从 'gradle' 更改为 'intelliJ'
解决
我对 运行ning 测试 classes 本身有疑问。将我的 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.
发生了什么问题已通过将 gradle 运行 配置中的值 'run tests' 从 'gradle' 更改为 'intelliJ'
解决