@@ -363,7 +363,7 @@ failed can be achieved as follows.
363363
364364[source,java,indent=0]
365365----
366- include::example$java/example/UsingTheLauncherDemo.java[tags=cancellation]
366+ include::example$java/example/UsingTheLauncherDemo.java[tags=cancellation-direct ]
367367----
368368<1> Create a `{CancellationToken}`
369369<2> Implement a `{TestExecutionListener}` that calls `cancel()` when a test fails
@@ -387,3 +387,37 @@ At the time of writing, the following test engines support cancellation:
387387* `{junit-platform-suite-engine}`
388388* Any `{TestEngine}` extending `{HierarchicalTestEngine}` such as Spock and Cucumber
389389====
390+
391+ [[launcher-cancellation-execution-request-from-discovery-request]]
392+ === Building a LauncherExecutionRequest from a LauncherDiscoveryRequest
393+
394+ Rather than building a `{LauncherExecutionRequest}` by starting with a
395+ `{LauncherDiscoveryRequestBuilder}` and calling `forExecution()`, you can create a
396+ `{LauncherExecutionRequestBuilder}` from a previously built `{LauncherDiscoveryRequest}`.
397+
398+ [source,java,indent=0]
399+ ----
400+ include::example$java/example/UsingTheLauncherDemo.java[tags=cancellation-discovery-request]
401+ ----
402+ <1> Build a `{LauncherDiscoveryRequest}`
403+ <2> Create a `{LauncherExecutionRequestBuilder}` with it
404+ <3> Register the cancellation token
405+ <4> Register the listener
406+ <5> Pass the `{LauncherExecutionRequest}` to `Launcher.execute`
407+
408+ [[launcher-cancellation-execution-request-from-test-plan]]
409+ === Building a LauncherExecutionRequest from a TestPlan
410+
411+ Alternatively, a `{LauncherExecutionRequestBuilder}` can be created from a previously
412+ discovered `{TestPlan}`.
413+
414+ [source,java,indent=0]
415+ ----
416+ include::example$java/example/UsingTheLauncherDemo.java[tags=cancellation-test-plan]
417+ ----
418+ <1> Build a `{LauncherDiscoveryRequest}`
419+ <2> Discover a `{TestPlan}` via `Launcher.discover`
420+ <3> Create a `{LauncherExecutionRequestBuilder}` with it
421+ <4> Register the cancellation token
422+ <5> Register the listener
423+ <6> Pass the `{LauncherExecutionRequest}` to `Launcher.execute`
0 commit comments