Java Magazine, Nov/Dec 2016
ORACLE COM JAVAMAGAZINE NOVEMBER DECEMBER 2016 22 junit 5 artifactId version 100 M2 version dependency dependencies plugin The JUnit team developed the junit platform surefireprovider dependency and its aim is to enable running both JUnit Vintage and JUnit Jupiter tests through Surefires mechanism The dependency doesnt yet support advanced parameters of Surefire such as forkCount and parallel but I believe the next iterations of the Surefire plugin will close that gap and will be 100 percent compatible with JUnit 5 Gradle integration Defining dependencies in Gradle is similar to defining them in Maven Jupiters engine and API definitions for Gradle are shown in Listing 4 Listing 4 dependencies testCompile org junit jupiter junit jupiter engine 500 M2 And the Vintage engine definition is given in Listing 5 Listing 5 dependencies testCompile org junit vintage junit vintage engine 4120 M2 To get the JUnit Gradle plugin hooked into the build the plugin should be declared and then applied in the configuration file as shown in Listing 6 Listing 6 buildscript repositories mavenCentral dependencies classpath org junit platform junit platform gradle plugin 100 M2 apply plugin org junit platform gradle plugin As shown in Listing 7 its also possible to configure the JUnit Gradle plugin with the junitPlatform directive with which I can define the engines for execution all engines are enabled by default by the way and test tags for inclusion or exclusion set a naming strategy for filtering test classes for execution specify a customized reports directory definition and specify a log manager configuration Listing 7 junitPlatform engines include junit jupiter junit vintage exclude custom engine tags include fast exclude slow includeClassNamePattern Test enableStandardTestTask true below is the default reports directory build test results junit platform
You must have JavaScript enabled to view digital editions.