首页 > 解决方案 > Gradle 不执行 scalatest

问题描述

我为我的 spark 项目创建了 scalatest,当我运行 gradle 任务“test”时,它不会执行单个测试。它显示零测试。

即使作为构建过程的一部分,gradle 也不执行任何测试用例。似乎 gradle 无法发现任何测试。

Build.gradle:
============
plugins {
    id "maven-publish"
    id "scala"
    id 'java'
    id 'jacoco'
}
scala {
    zincVersion = "1.2.1"
}

repositories {
    mavenLocal()
    jcenter()
    mavenCentral()
    maven {
        url 'http://conjars.org/repo'
    }
}
dependencies {
    compile "org.scala-lang:scala-library:"+scalaVersion
    compile "org.scala-lang:scala-reflect:"+scalaVersion
    compile "org.scala-lang:scala-compiler:"+scalaVersion
    compile('org.apache.spark:spark-core_2.12:2.4.6')
    compile('org.apache.spark:spark-sql_2.12:2.4.6')
    compile('com.typesafe.scala-logging:scala-logging-slf4j_2.11:2.1.2')
    compile('ch.hsr:geohash:1.3.0')
    compile('joda-time:joda-time:2.3')
    compile('org.json4s:json4s-jackson_2.11:3.7.0-M4')
    compile('org.apache.httpcomponents:httpclient:4.5.6')
    compile('com.fasterxml.jackson.datatype:jackson-datatype-joda:2.5.1')
    compile 'com.typesafe:config:1.4.1'
    implementation 'com.google.guava:guava:29.0-jre'
    testCompile 'junit:junit:4.12'
    testCompile 'org.scalatest:scalatest_2.12:3.2.0'
    testCompile ("org.mockito:mockito-scala_2.12:1.16.42")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.7.0")
    testImplementation("org.junit.jupiter:junit-jupiter-api:5.4.2")
    testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.4.2")
    testCompile group: 'com.holdenkarau', name: 'spark-testing-base_2.12', version: '2.4.5_1.0.0'
    compile 'org.scala-lang.modules:scala-xml_2.12:1.2.0'
}
test {
    useJUnitPlatform()
    testLogging {
        events "passed", "skipped", "failed"
    }
}

标签: scalaunit-testingapache-sparkgradlescalatest

解决方案


推荐阅读