[英]Can't run my test class with testng config
I have an issue with running test classes on it's own.我对自己运行测试类有疑问。 After updating my IntelliJ IDEA from version 2018 to 2020 i can't run tests on it's own using testNG it runs through the Gradle and don't work.将我的 IntelliJ IDEA 从版本 2018 更新到 2020 后,我无法使用 testNG 自行运行测试,它通过 Gradle 运行并且不起作用。
My build.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
}
I can still run any xml file using testNG without problems, but can't understand what happened with single configure class.我仍然可以使用 testNG 毫无问题地运行任何 xml 文件,但无法理解单个配置 class 发生了什么。
The problem had been resolved by changing value 'run tests' in gradle run configuration from 'gradle' to 'intelliJ'该问题已通过将 gradle 运行配置中的值“运行测试”从“gradle”更改为“intelliJ”来解决
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.