gpt4 book ai didi

Scalatest Maven 插件 "no tests were executed"

转载 作者:行者123 更新时间:2023-12-03 15:47:44 25 4
gpt4 key购买 nike

我正在尝试使用 scalatestspark-testing-base在 Maven 上集成测试 Spark。 Spark 作业读入一个 CSV 文件,验证结果,并将数据插入到数据库中。我试图通过放入已知格式的文件并查看它们是否以及如何失败来测试验证。这个特殊的测试只是确保验证通过。不幸的是,scalatest 找不到我的测试。

相关pom插件:

        <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- enable scalatest -->
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
<wildcardSuites>com.cainc.data.etl.schema.proficiency</wildcardSuites>
</configuration>
<executions>
<execution>
<id>test</id>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>

这是测试类:
class ProficiencySchemaITest extends FlatSpec with Matchers with SharedSparkContext with BeforeAndAfter {
private var schemaStrategy: SchemaStrategy = _
private var dataReader: DataFrameReader = _

before {
val sqlContext = new SQLContext(sc)
import sqlContext._
import sqlContext.implicits._

val dataInReader = sqlContext.read.format("com.databricks.spark.csv")
.option("header", "true")
.option("nullValue", "")
schemaStrategy = SchemaStrategyChooser("dim_state_test_proficiency")
dataReader = schemaStrategy.applySchema(dataInReader)
}

"Proficiency Validation" should "pass with the CSV file proficiency-valid.csv" in {
val dataIn = dataReader.load("src/test/resources/proficiency-valid.csv")

val valid: Try[DataFrame] = Try(schemaStrategy.validateCsv(dataIn))
valid match {
case Success(v) => ()
case Failure(e) => fail("Validation failed on what should have been a clean file: ", e)
}
}
}

当我跑 mvn test ,它找不到任何测试并输出此消息:
[INFO] --- scalatest-maven-plugin:1.0:test (test) @ load-csv-into-db ---
[36mDiscovery starting.[0m
[36mDiscovery completed in 54 milliseconds.[0m
[36mRun starting. Expected test count is: 0[0m
[32mDiscoverySuite:[0m
[36mRun completed in 133 milliseconds.[0m
[36mTotal number of tests run: 0[0m
[36mSuites: completed 1, aborted 0[0m
[36mTests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0[0m
[33mNo tests were executed.[0m

更新
通过使用:
<suites>com.cainc.data.etl.schema.proficiency.ProficiencySchemaITest</suites>

代替:
<wildcardSuites>com.cainc.data.etl.schema.proficiency</wildcardSuites>

我可以让那个测试运行。显然,这并不理想。可能通配符套件已损坏;我将在 GitHub 上开一张票,看看会发生什么。

最佳答案

这可能是因为项目路径中有一些空格字符。
删除项目路径中的空间,可以成功发现测试。
希望这有帮助。

关于Scalatest Maven 插件 "no tests were executed",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38700319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com