ScalaTest Junit 5 runner
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
scala_lib_version=2.12
scala_version=2.12.10
junit_platform_version=1.6.0
build.gradle
plugins {
id 'scala'
}
repositories {
jcenter()
}
dependencies {
implementation "org.scala-lang:scala-library:$scala_version"
testImplementation "org.scalatest:scalatest_$scala_lib_version:3.2.0-M3"
testRuntime "org.junit.platform:junit-platform-engine:$junit_platform_version"
testRuntime "org.junit.platform:junit-platform-launcher:$junit_platform_version"
testRuntime "co.helmethair:scalatest-junit-runner:0.1.11"
}
test {
useJUnitPlatform {
includeEngines 'scalatest'
testLogging {
events("passed", "skipped", "failed")
}
}
}
See example Groovy Gradle project
Kotlin DSL
build.gradle.kts
...
tasks {
test{
useJUnitPlatform {
includeEngines("scalatest")
testLogging {
events("passed", "skipped", "failed")
}
}
}
}
See example Kotlin DSL Gradle project
Maven
Surefire plugin version >= 2.22.0
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project ...
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
<scope>compile</scope>
</dependency>
<!-- junit 5 -->
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<!-- scalatest -->
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.compat.version}</artifactId>
<version>${scalatest.version}</version>
<scope>test</scope>
</dependency>
<!-- scalatest junit 5 runner -->
<dependency>
<groupId>co.helmethair</groupId>
<artifactId>scalatest-junit-runner</artifactId>
<version>${scalatest.runner.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</plugin>
...
</plugins>
</build>
</project>
JUnit console
Add the library to the classpath and run your test
Built With
- ScalaTest
- Kotlin - Kotlin DSL for Gralde
- Gradle - Build tool
- Gradle Test Logger Plugin
- semver-git-plugin
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