Libraries

ScalaTest + Play

ScalaTest + Selenium

ScalaTest + ScalaCheck

ScalaTest + JUnit 4

ScalaTest + JUnit 5

ScalaTest + TestNG

ScalaTest + EasyMock

ScalaTest + JMock

ScalaTest + Mockito

ScalaTest + JUnit 5

The ScalaTest + JUnit 5 integration library makes it fun and easy to use JUnit 5 with ScalaTest.

ScalaTest + JUnit 5 provides the following features:

  • ScalaTest JUnit test engine implementation, this allows ScalaTest suites to be run by JUnit 5 platform, include or exclude ScalaTest suites through tags is supported.
  • The JUnitSuiteLike and JUnitSuite trait that can be run by either ScalaTest runner or JUnit 5 platform.

To use ScalaTest + JUnit 5, please add the following to your SBT project dependency:

libraryDependencies += "org.scalatestplus" %% "junit-5-10" % "3.2.18.0" % "test"

For maven you can use:

<dependency>
    <groupId>org.scalatestplus</groupId>
    <artifactId>junit-5-10_3</artifactId>
    <version>3.2.18.0</version>
    <scope>test</scope>
</dependency>

For gradle you can use:

dependencies {
    implementation "org.scala-lang:scala-library:3.3.1"

    testImplementation "org.scalatest:scalatest_2.13:3.2.18"
    testImplementation "org.junit.platform:junit-platform-launcher:1.10.0"
    testRuntimeOnly "org.junit.platform:junit-platform-engine:1.10.0"
    testRuntimeOnly "org.scalatestplus:junit-5-10_2.13:3.2.18.0"
}

test {
    useJUnitPlatform {
        includeEngines 'scalatest'
        testLogging {
            events("passed", "skipped", "failed", "standard_error")
        }
    }
}

For gradle (Kotlin) you can use:

dependencies {
    implementation("org.scala-lang:scala-library:3.2.18")

    testImplementation("org.scalatest:scalatest_2.13:3.2.18")
    testRuntimeOnly("org.junit.platform:junit-platform-engine:1.10.0")
    testRuntimeOnly("org.junit.platform:junit-platform-launcher:1.10.0")
    testRuntimeOnly("org.scalatestplus:junit-5-10_2.13:3.2.18.0")
}

tasks {
    test{
        useJUnitPlatform {
            includeEngines("scalatest")
            testLogging {
                events("passed", "skipped", "failed")
            }
        }
    }
}

For Gradle project, by default IntelliJ IDEA uses Gradle's test runner to run tests, which at the time of writing does not work with Jump to Source feature. You may switch to use IntelliJ IDEA's test runner by following the instructions here.

ScalaTest is brought to you by Bill Venners and Artima.
ScalaTest is free, open-source software released under the Apache 2.0 license.

If your company loves ScalaTest, please consider sponsoring the project.

Copyright © 2009-2024 Artima, Inc. All Rights Reserved.

artima