/*
 * Copyright 2015-2018 the original author or authors.
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v2.0 which
 * accompanies this distribution and is available at
 *
 * http://www.eclipse.org/legal/epl-v20.html
 */

package example.testkit;

// @formatter:off
// tag::user_guide[]

import static org.assertj.core.api.Assertions.allOf;
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
import static org.junit.platform.testkit.engine.EventConditions.event;
import static org.junit.platform.testkit.engine.EventConditions.finishedWithFailure;
import static org.junit.platform.testkit.engine.EventConditions.test;
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.isA;
import static org.junit.platform.testkit.engine.TestExecutionResultConditions.message;

import example.ExampleTestCase;

import org.junit.jupiter.api.Test;
import org.junit.platform.testkit.engine.EngineTestKit;

class EngineTestKitFailedMethodDemo {

	@Test
	void verifyJupiterMethodFailed() {
		EngineTestKit.engine("junit-jupiter") // <1>
				.selectors(selectClass(ExampleTestCase.class)) // <2>
				.execute() // <3>
				.tests() // <4>
				.assertThatEvents().haveExactly(1, // <5>
					event(test("failingTest"),
						finishedWithFailure(allOf(isA(ArithmeticException.class), message("/ by zero")))));
	}

}
// end::user_guide[]
// @formatter:on

@@ -1162,17 +1162,16 @@
  %3C1%3E%0A%09%09%09
-%09
 .selecto
@@ -1219,17 +1219,16 @@
  %3C2%3E%0A%09%09%09
-%09
 .execute
@@ -1240,17 +1240,16 @@
  %3C3%3E%0A%09%09%09
-%09
 .tests()
@@ -1256,17 +1256,16 @@
  // %3C4%3E%0A
-%09
 %09%09%09.asse
@@ -1305,17 +1305,16 @@
 %3C5%3E%0A%09%09%09%09
-%09
 event(te
@@ -1337,17 +1337,16 @@
 ),%0A%09%09%09%09%09
-%09
 finished
@@ -1357,16 +1357,23 @@
 Failure(
+%0A%09%09%09%09%09%09
 allOf(is

Fix code line wrapping in User Guide