项目作者: helmethair-co

项目描述 :
JUnit 5 runner for Scalatest
高级语言: Java
项目地址: git://github.com/helmethair-co/scalatest-junit-runner.git
创建时间: 2020-02-28T20:43:39Z
项目社区:https://github.com/helmethair-co/scalatest-junit-runner

开源协议:MIT License

下载


ScalaTest Junit 5 runner

Tests
codecov
Maven Central

JUnit 5 runner library for ScalaTest tests. It can be used to fully integrate ScalaTest into Gradle (version >= 4.5) and to Maven.

There is an open issue to natively support JUnit 5 in ScalaTest without this library.

Getting Started

Features

  • Running ScalaTest test on the Junit 5 platform
  • Fully integrate ScalaTest into gradle
  • Report individual test runs
  • Report errors to JUnit 5 with stack traces
  • Support ScalaTest tags
  • Optional early stopping after the first test fail

How to use

Gradle

version >= 4.5
This library allows to run ScalaTest on the new JUnit Platform (JUnit 5)
To run ScalaTest on the old JUnit Vintage (JUnit 4) platform use the gradle-scalatest Gradle plugin.

Groovy

gradle.properties

  1. scala_lib_version=2.12
  2. scala_version=2.12.10
  3. junit_platform_version=1.6.0

build.gradle

  1. plugins {
  2. id 'scala'
  3. }
  4. repositories {
  5. jcenter()
  6. }
  7. dependencies {
  8. implementation "org.scala-lang:scala-library:$scala_version"
  9. testImplementation "org.scalatest:scalatest_$scala_lib_version:3.2.0-M3"
  10. testRuntime "org.junit.platform:junit-platform-engine:$junit_platform_version"
  11. testRuntime "org.junit.platform:junit-platform-launcher:$junit_platform_version"
  12. testRuntime "co.helmethair:scalatest-junit-runner:0.1.11"
  13. }
  14. test {
  15. useJUnitPlatform {
  16. includeEngines 'scalatest'
  17. testLogging {
  18. events("passed", "skipped", "failed")
  19. }
  20. }
  21. }

See example Groovy Gradle project

Kotlin DSL

build.gradle.kts

  1. ...
  2. tasks {
  3. test{
  4. useJUnitPlatform {
  5. includeEngines("scalatest")
  6. testLogging {
  7. events("passed", "skipped", "failed")
  8. }
  9. }
  10. }
  11. }

See example Kotlin DSL Gradle project

Maven

Surefire plugin version >= 2.22.0

pom.xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <project ...
  3. <dependencies>
  4. <dependency>
  5. <groupId>org.scala-lang</groupId>
  6. <artifactId>scala-library</artifactId>
  7. <version>${scala.version}</version>
  8. <scope>compile</scope>
  9. </dependency>
  10. <!-- junit 5 -->
  11. <dependency>
  12. <groupId>org.junit.platform</groupId>
  13. <artifactId>junit-platform-engine</artifactId>
  14. <version>${junit.version}</version>
  15. <scope>test</scope>
  16. </dependency>
  17. <!-- scalatest -->
  18. <dependency>
  19. <groupId>org.scalatest</groupId>
  20. <artifactId>scalatest_${scala.compat.version}</artifactId>
  21. <version>${scalatest.version}</version>
  22. <scope>test</scope>
  23. </dependency>
  24. <!-- scalatest junit 5 runner -->
  25. <dependency>
  26. <groupId>co.helmethair</groupId>
  27. <artifactId>scalatest-junit-runner</artifactId>
  28. <version>${scalatest.runner.version}</version>
  29. <scope>test</scope>
  30. </dependency>
  31. </dependencies>
  32. <build>
  33. <sourceDirectory>src/main/scala</sourceDirectory>
  34. <testSourceDirectory>src/test/scala</testSourceDirectory>
  35. <plugins>
  36. ...
  37. <plugin>
  38. <groupId>org.apache.maven.plugins</groupId>
  39. <artifactId>maven-surefire-plugin</artifactId>
  40. <version>${maven.surefire.version}</version>
  41. </plugin>
  42. ...
  43. </plugins>
  44. </build>
  45. </project>

See example maven project

JUnit console

Add the library to the classpath and run your test

Built With

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

We use semantic versioning.

This project is licensed under the MIT License - see the LICENSE for details