Java Code Examples for org.junit.jupiter.api.DynamicTest#dynamicTest()

The following examples show how to use org.junit.jupiter.api.DynamicTest#dynamicTest() . 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: FeatureNode.java    From karate with MIT License 6 votes vote down vote up
@Override
public DynamicTest next() {
    ScenarioExecutionUnit unit = iterator.next();
    return DynamicTest.dynamicTest(unit.scenario.getNameForReport(), () -> {
        featureUnit.run(unit);
        boolean failed = unit.result.isFailed();
        if (unit.isLast() || failed) {
            featureUnit.stop();
            exec.result.printStats(null);
            Engine.saveResultHtml(FileUtils.getBuildDir() + File.separator + "surefire-reports", exec.result, null);
        }
        if (failed) {
            Assertions.fail(unit.result.getError().getMessage());
        }
    });
}
 
Example 2
Source File: NodeAcceptTest.java    From gyro with Apache License 2.0 5 votes vote down vote up
<N extends Node> DynamicTest create(Class<N> nodeClass, Verifier<N> verifier) {
    return DynamicTest.dynamicTest(nodeClass.getName(), () -> {
        @SuppressWarnings("unchecked")
        NodeVisitor<Object, Object, RuntimeException> visitor = mock(NodeVisitor.class, CALLS_REAL_METHODS);
        N node = mock(nodeClass, CALLS_REAL_METHODS);

        visitor.visit(node, null);
        verify(visitor).visit(node, null);
        node.accept(visitor, null);
        verifier.verify(verify(visitor, times(2)), node, null);
        verifyNoMoreInteractions(visitor);
    });
}
 
Example 3
Source File: WorkingDaysToDaysConverterTest.java    From taskana with Apache License 2.0 5 votes vote down vote up
@TestFactory
Stream<DynamicTest> should_NotDetectCorpusChristiAsHoliday_When_CorpusChristiIsDisabled() {
  DynamicTest year1980 =
      DynamicTest.dynamicTest(
          "year 1980",
          () -> assertThat(converter.isGermanHoliday(LocalDate.parse("1980-06-05"))).isFalse());
  DynamicTest year2020 =
      DynamicTest.dynamicTest(
          "year 2020",
          () -> assertThat(converter.isGermanHoliday(LocalDate.parse("2020-06-11"))).isFalse());
  return Stream.of(year1980, year2020);
}
 
Example 4
Source File: WorkingDaysToDaysConverterTest.java    From taskana with Apache License 2.0 5 votes vote down vote up
@TestFactory
Stream<DynamicNode> should_DetectCorpusChristiAsHoliday_When_CorpusChristiIsEnabled() {
  WorkingDaysToDaysConverter converter = new WorkingDaysToDaysConverter(true, true);
  DynamicTest year1980 =
      DynamicTest.dynamicTest(
          "year 1980",
          () -> assertThat(converter.isGermanHoliday(LocalDate.parse("1980-06-05"))).isTrue());
  DynamicTest year2020 =
      DynamicTest.dynamicTest(
          "year 2020",
          () -> assertThat(converter.isGermanHoliday(LocalDate.parse("2020-06-11"))).isTrue());
  return Stream.of(year1980, year2020);
}
 
Example 5
Source File: BaseOperatorTest.java    From reactor-core with Apache License 2.0 5 votes vote down vote up
private DynamicTest toDynamicTest(OperatorScenario<I, PI, O, PO> scenario, ThrowingRunnable runnable) {
	return DynamicTest.dynamicTest(scenario.description(), () -> {
		if (scenario.stack != null) {
			System.out.println("\tat " + scenario.stack.getStackTrace()[2]);
		}
		runnable.run();
	});
}