org.junit.platform.testkit.engine.EngineTestKit Java Examples

The following examples show how to use org.junit.platform.testkit.engine.EngineTestKit. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ParallelExecutionTest.java    From dropwizard-guicey with MIT License 6 votes vote down vote up
@Test
void checkParallelExecution() {
    EngineTestKit
            .engine("junit-jupiter")
            .configurationParameter("junit.jupiter.conditions.deactivate", "org.junit.*DisabledCondition")
            .configurationParameter("junit.jupiter.execution.parallel.enabled", "true")
            .configurationParameter("junit.jupiter.execution.parallel.mode.default", "concurrent")
            .selectors(selectClass(Test1.class),
                    selectClass(Test2.class),
                    selectClass(Test3.class),
                    selectClass(Test4.class))
            .execute()
            .testEvents()
            .debug()
            .assertStatistics(stats -> stats.succeeded(4));
}
 
Example #2
Source File: LoggingExtensionTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
void checkSuccessLogs() {
	EngineTestKit.engine("junit-jupiter")
		.selectors(selectMethod(FakeTest.class, "success"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(0).succeeded(1).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(SUCCESS_HEADER);
	assertThat(logs).contains(SUCCESS_FOOTER);
}
 
Example #3
Source File: LoggingExtensionTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
void checkFailureLogs() {
	EngineTestKit.engine("junit-jupiter")
		.selectors(selectMethod(FakeTest.class, "failure"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(1).succeeded(0).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(FAILURE_HEADER);
	assertThat(logs).contains(FAILURE_FOOTER);
}
 
Example #4
Source File: LoggingExtensionTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
void checkCaughtLogs() {
	EngineTestKit.engine("junit-jupiter")
		.selectors(selectMethod(FakeTest.class, "caught"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(0).succeeded(1).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(CAUGHT_HEADER);
	assertThat(logs).contains(CAUGHT_FOOTER);
}
 
Example #5
Source File: LoggingRuleTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void checkSuccessLogs() {
	EngineTestKit.engine("junit-vintage")
		.selectors(selectMethod(FakeTest.class, "success"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(0).succeeded(1).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(SUCCESS_HEADER);
	assertThat(logs).contains(SUCCESS_FOOTER);
}
 
Example #6
Source File: LoggingRuleTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void checkFailureLogs() {
	EngineTestKit.engine("junit-vintage")
		.selectors(selectMethod(FakeTest.class, "failure"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(1).succeeded(0).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(FAILURE_HEADER);
	assertThat(logs).contains(FAILURE_FOOTER);
}
 
Example #7
Source File: LoggingRuleTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void checkCaughtLogs() {
	EngineTestKit.engine("junit-vintage")
		.selectors(selectMethod(FakeTest.class, "caught"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(0).succeeded(1).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(CAUGHT_HEADER);
	assertThat(logs).contains(CAUGHT_FOOTER);
}
 
Example #8
Source File: LoggingRuleTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void checkCaughtByAnnotationLogs() {
	EngineTestKit.engine("junit-vintage")
		.selectors(selectMethod(FakeTest.class, "caughtByAnnotation"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(0).succeeded(1).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(CAUGHT_ANNOTATION_HEADER);
	assertThat(logs).contains(CAUGHT_ANNOTATION_FOOTER);
}
 
Example #9
Source File: LoggingRuleTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void checkAnnotatedSuccessLogs() {
	EngineTestKit.engine("junit-vintage")
		.selectors(selectMethod(FakeTest.class, "success"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(0).succeeded(1).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(SUCCESS_HEADER);
	assertThat(logs).contains(SUCCESS_FOOTER);
}
 
Example #10
Source File: LoggingRuleTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void checkAnnotatedFailureLogs() {
	EngineTestKit.engine("junit-vintage")
		.selectors(selectMethod(FakeTest.class, "failure"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(1).succeeded(0).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(FAILURE_HEADER);
	assertThat(logs).contains(FAILURE_FOOTER);
}
 
Example #11
Source File: LoggingRuleTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void checkAnnotatedCaughtLogs() {
	EngineTestKit.engine("junit-vintage")
		.selectors(selectMethod(FakeTest.class, "caught"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(0).succeeded(1).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(CAUGHT_HEADER);
	assertThat(logs).contains(CAUGHT_FOOTER);
}
 
Example #12
Source File: LoggingRuleTest.java    From ogham with Apache License 2.0 5 votes vote down vote up
@Test
public void checkAnnotatedCaughtByAnnotationLogs() {
	EngineTestKit.engine("junit-vintage")
		.selectors(selectMethod(FakeTest.class, "caughtByAnnotation"))
		.execute()
			.testEvents()
				.assertStatistics(s -> s.aborted(0).failed(0).succeeded(1).skipped(0));
	String logs = writer.toString();
	assertThat(logs).contains(CAUGHT_ANNOTATION_HEADER);
	assertThat(logs).contains(CAUGHT_ANNOTATION_FOOTER);
}
 
Example #13
Source File: BadHookFieldDeclaration.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@Test
void checkIncorrectFieldDetection() {
    EngineTestKit
            .engine("junit-jupiter")
            .configurationParameter("junit.jupiter.conditions.deactivate", "org.junit.*DisabledCondition")
            .selectors(selectClass(Test1.class))
            .execute()
            .testEvents()
            .debug()
            .assertStatistics(stats -> stats.succeeded(0));
}
 
Example #14
Source File: GuiceyExtensionShutdownTest.java    From dropwizard-guicey with MIT License 5 votes vote down vote up
@Test
void checkParallelExecution() {
    EngineTestKit
            .engine("junit-jupiter")
            .selectors(selectClass(Test1.class))
            .execute()
            .testEvents()
            .debug()
            .assertStatistics(stats -> stats.succeeded(1));

    Assertions.assertTrue(App.shutdown);
}
 
Example #15
Source File: TestKitExtensionTest.java    From exonum-java-binding with Apache License 2.0 4 votes vote down vote up
private EngineExecutionResults getTestCaseEngineExecutionResults(Class<?> testCaseClass) {
  return EngineTestKit.engine("junit-jupiter")
      .selectors(selectClass(testCaseClass))
      .execute();
}