O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Legacy tests wih Gradle

If we want to execute the same test presented in the example before (io.github.bonigarcia.LegacyJUnit4Test), but this time using Gradle, we need to include the following in our build.gradle file:

  • The dependency for JUnit 4.12.
  • The dependency for the Test Engine (junit-vintage-engine).
  • The plugin for the Test Launcher (junit-platform-gradle-plugin).

Thus, the complete source of build.gradle would be as follows:

buildscript {   repositories {      mavenCentral()   }   dependencies {      classpath("org.junit.platform:junit-platform-gradle-plugin:${junitPlatformVersion}")   }}repositories {   mavenCentral()}apply plugin: 'java'apply plugin: 'eclipse'apply plugin: 'idea'apply plugin: 'org.junit.platform.gradle.plugin'compileTestJava {

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required