anchor.diff:  [[running-tests-build-gradle]]
   ==== Gradle
   
  -The JUnit team has developed a very basic Gradle plugin that allows you to run any kind
  -of test that is supported by a `TestEngine` (e.g., JUnit 3, JUnit 4, JUnit Jupiter,
  -{Specsy}, etc.). See `build.gradle` in the `{junit5-gradle-consumer}` project for an
  -example of the plugin in action.
  -
  -[[running-tests-build-gradle-junit-enable]]
  -===== Enabling the JUnit Gradle Plugin
  -
  -To use the JUnit Gradle plugin, you first need to make sure that you are running Gradle
  -2.5 or higher. Once you've done that, you can configure `build.gradle` as follows.
  -
  -[source,java,indent=0]
  -[subs=attributes+]
  -----
  -buildscript {
  -	repositories {
  -		mavenCentral()
  -		// The following is only necessary if you want to use SNAPSHOT releases.
  -		// maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
  -	}
  -	dependencies {
  -		classpath 'org.junit.platform:junit-platform-gradle-plugin:{platform-version}'
  +Starting with https://docs.gradle.org/4.6/release-notes.html[version 4.6], Gradle provides
  +https://docs.gradle.org/current/userguide/java_plugin.html#using_junit5[native support]
  +for executing tests on the JUnit Platform. To enable it, you just need to add one line to
  +your `build.gradle`:
  +
  +[source,java,indent=0]
  +[subs=attributes+]
  +----
  +test {
  +    useJUnitPlatform()
  +}
  +----
  +
  +Filtering by tags or engines is also supported:
  +
  +[source,java,indent=0]
  +[subs=attributes+]
  +----
  +test {
  +    useJUnitPlatform {
  +        includeTags 'fast', 'smoke & feature-a'
  +        excludeTags 'slow', 'ci'
  +        includeEngines 'junit-jupiter'
  +        excludeEngines 'junit-vintage'
   	}
   }
  -
  -apply plugin: 'org.junit.platform.gradle.plugin'
  -----
  -
  -[[running-tests-build-gradle-junit-configure]]
  -===== Configuring the JUnit Gradle Plugin
  -
  -Once the JUnit Gradle plugin has been applied, you can configure it as follows.
  -
  -[source,java,indent=0]
  -[subs=attributes+]
  -----
  -junitPlatform {
  -	platformVersion '{platform-version}' // optional, defaults to plugin version
  -	reportsDir file('build/test-results/junit-platform') // this is the default
  -	// enableStandardTestTask true
  -	// selectors (optional)
  -	// filters (optional)
  -	// logManager (optional)
  -}
  -----
  -
  -By default, the JUnit Gradle plugin disables the standard Gradle `test` task, but this
  -can be overridden via the `enableStandardTestTask` flag.
  -
  -[[running-tests-build-gradle-selectors]]
  -===== Configuring Selectors
  -
  -By default, the plugin will scan your project's output directories for tests. However,
  -you can specify which tests to execute explicitly using the `selectors` extension element.
  -
  -[source,java,indent=0]
  -----
  -junitPlatform {
  +----
  +
  +Please refer to the
  +https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_test[official Gradle documentation]
  +for a comprehensive list of options.
  +
  +[WARNING]
  +.The JUnit Platform Gradle Plugin is deprecated
  +====
  +The very basic `junit-platform-gradle-plugin` developed by the JUnit team was deprecated
  +in JUnit Platform 1.2 and will be discontinued in 1.3. Please switch to Gradle's standard
  +`test` task.
  +====
  +
  +[[running-tests-build-gradle-config-params]]
  +===== Configuration Parameters
  +
  +The standard `test` tasks does currently not provide a dedicated DSL to set configuration
  +parameters to influence test discovery and execution. However, you can use system
  +properties instead.
  +
  +[source,java,indent=0]
  +----
  +test {
   	// ...
  -	selectors {
  -		uris 'file:///foo.txt', 'http://example.com/'
  -		uri 'foo:resource' <1>
  -		files 'foo.txt', 'bar.csv'
  -		file 'qux.json' <2>
  -		directories 'foo/bar', 'bar/qux'
  -		directory 'qux/bar' <3>
  -		packages 'com.acme.foo', 'com.acme.bar'
  -		aPackage 'com.example.app' <4>
  -		classes 'com.acme.Foo', 'com.acme.Bar'
  -		aClass 'com.example.app.Application' <5>
  -		methods 'com.acme.Foo#a', 'com.acme.Foo#b'
  -		method 'com.example.app.Application#run(java.lang.String[])' <6>
  -		resources '/bar.csv', '/foo/input.json'
  -		resource '/com/acme/my.properties' <7>
  -		modules 'foo', 'bar'
  -		module 'baz' <8>
  -	}
  +	systemProperty 'junit.jupiter.conditions.deactivate', '*'
  +	systemProperties = [
  +		'junit.jupiter.extensions.autodetection.enabled': 'true',
  +		'junit.jupiter.testinstance.lifecycle.default': 'per_class'
  +	]
   	// ...
   }
   ----
  -<1> URIs
  -<2> Local files
  -<3> Local directories
  -<4> Packages
  -<5> Classes, fully qualified class names
  -<6> Methods, fully qualified method names (see {DiscoverySelectors_selectMethod})
  -<7> Classpath resources
  -<8> Module names
  -
  -[[running-tests-build-gradle-filters]]
  -===== Configuring Filters
  -
  -You can configure filters for the test plan by using the `filters` extension. By default,
  -all engines and tags are included in the test plan. Only the default
  -`includeClassNamePattern` (`{standard-include-class-name-pattern}`) is applied. You can
  -override the default pattern as in the following example. When you specify multiple
  -patterns, they are combined using OR semantics.
  -
  -[source,java,indent=0]
  -----
  -junitPlatform {
  -	// ...
  -	filters {
  -		engines {
  -			include 'junit-jupiter'
  -			// exclude 'junit-vintage'
  -		}
  -		tags {
  -			include 'fast', 'smoke & feature-a'
  -			// exclude 'slow', 'ci'
  -		}
  -		packages {
  -			include 'com.sample.included1', 'com.sample.included2'
  -			// exclude 'com.sample.excluded1', 'com.sample.excluded2'
  -		}
  -		includeClassNamePattern '.*Spec'
  -		includeClassNamePatterns '.*Test', '.*Tests'
  -	}
  -	// ...
  -}
  -----
  -
  -If you supply a _Test Engine ID_ via `engines {include ...}` or `engines {exclude ...}`,
  -the JUnit Gradle plugin will only run tests for the desired test engines. Similarly, if
  -you supply _tags_ or <<running-tests-tag-expressions, _tag expressions_>> via
  -`tags {include ...}` or `tags {exclude ...}`, the JUnit Gradle plugin will only run tests
  -that are _tagged_ accordingly (e.g., via the `@Tag` annotation for JUnit Jupiter based
  -tests). The same applies to package names that can be included or excluded using
  -`packages {include ...}` or `packages {exclude ...}`.
  -
  -[[running-tests-build-gradle-config-params]]
  -===== Configuration Parameters
  -
  -You can set configuration parameters to influence test discovery and execution by using
  -the `configurationParameter` or `configurationParameters` DSL. The former can be used to
  -set a single configuration parameter, while the latter takes a map of configuration
  -parameters to set multiple key-value pairs at once. All keys and values must be `Strings`.
  -
  -[source,java,indent=0]
  -----
  -junitPlatform {
  -	// ...
  -	configurationParameter 'junit.jupiter.conditions.deactivate', '*'
  -	configurationParameters([
  -		'junit.jupiter.extensions.autodetection.enabled': 'true',
  -		'junit.jupiter.testinstance.lifecycle.default': 'per_class'
  -	])
  -	// ...
  -}
  -----
   
   [[running-tests-build-gradle-engines-configure]]
   ===== Configuring Test Engines
   
  -In order to have the JUnit Gradle plugin run any tests at all, a `TestEngine`
  -implementation must be on the classpath.
  +In order to run any tests at all, a `TestEngine` implementation must be on the classpath.
   
   To configure support for JUnit Jupiter based tests, configure a `testCompile` dependency
   on the JUnit Jupiter API and a `testRuntime` dependency on the JUnit Jupiter `TestEngine`
  
positive.code: [source,java,indent=0]
  [subs=attributes+]
  ----
  junitPlatform {
  	logManager 'org.apache.logging.log4j.jul.LogManager'
  }
  ----
  
  
negative.code: }
  ----
  
  The JUnit Platform can run JUnit 4 based tests as long as you configure a
  `testCompile` dependency on JUnit 4 and a `testRuntime` dependency on the JUnit Vintage
  `TestEngine` implementation similar to the following.
  
  