当前位置: 首页>>代码示例>>Java>>正文


Java DynamicTest类代码示例

本文整理汇总了Java中org.junit.jupiter.api.DynamicTest的典型用法代码示例。如果您正苦于以下问题:Java DynamicTest类的具体用法?Java DynamicTest怎么用?Java DynamicTest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DynamicTest类属于org.junit.jupiter.api包,在下文中一共展示了DynamicTest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: streamTest

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Stream<DynamicTest> streamTest() {
    // Input data
    Integer array[] = { 1, 2, 3 };
    Iterator<Integer> inputGenerator = Arrays.asList(array).iterator();

    // Display names
    Function<Integer, String> displayNameGenerator = (
            input) -> "Data input:" + input;

    // Test executor
    ThrowingConsumer<Integer> testExecutor = (input) -> {
        System.out.println(input);
        assertTrue(input % 2 == 0);
    };

    // Returns a stream of dynamic tests
    return stream(inputGenerator, displayNameGenerator, testExecutor);
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:20,代码来源:StreamExampleTest.java

示例2: dynamicTestsFromStream

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
@Test
@Epic("epic1")
@Epic("epic2")
@Epic("epic3")
@Feature("feature1")
@Feature("feature2")
@Feature("feature3")
@Story("story1")
@Stories({
        @Story("story2"),
        @Story("story3")
})
@Owner("some-owner")
Stream<DynamicTest> dynamicTestsFromStream() {
    return Stream.of("A", "B", "C").map(str -> dynamicTest("test" + str, () -> {
    }));
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:19,代码来源:DynamicTests.java

示例3: queryTable

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
public Stream<DynamicTest> queryTable() throws SQLException {
  List<ChangeKey> changeCaptureTables = new ArrayList<>();
  PooledConnection pooledConnection = null;
  try {
    pooledConnection = JdbcUtils.openPooledConnection(this.config, new ChangeKey(MsSqlTestConstants.DATABASE_NAME, null, null));
    MsSqlQueryBuilder queryBuilder = new MsSqlQueryBuilder(pooledConnection.getConnection());
    try (PreparedStatement statement = queryBuilder.listChangeTrackingTablesStatement()) {
      try (ResultSet resultSet = statement.executeQuery()) {
        while (resultSet.next()) {
          String databaseName = resultSet.getString("databaseName");
          String schemaName = resultSet.getString("schemaName");
          String tableName = resultSet.getString("tableName");
          ChangeKey changeKey = new ChangeKey(databaseName, schemaName, tableName);
          changeCaptureTables.add(changeKey);
          log.trace("Found Change Tracking Enabled Table {}", changeKey);
        }
      }
    }
  } finally {
    JdbcUtils.closeConnection(pooledConnection);
  }

  return changeCaptureTables.stream().map(data -> dynamicTest(data.tableName, () -> queryTable(data)));
}
 
开发者ID:jcustenborder,项目名称:kafka-connect-cdc-mssql,代码行数:26,代码来源:QueryServiceTest.java

示例4: transformRstTest

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
DynamicTest transformRstTest(TransformationTemplate transformationTemplate, final String templateName, final File parentDirectory) {
  if (!parentDirectory.isDirectory()) {
    parentDirectory.mkdirs();
  }

  final String testName = transformationTemplate.getTestName();

  return dynamicTest(testName, () -> {
    final File outputFile = new File(parentDirectory, testName.toLowerCase() + ".rst");

    Template template = configuration.getTemplate(templateName);
    log.info("Writing {}", outputFile);
    try (Writer writer = Files.newWriter(outputFile, Charsets.UTF_8)) {
      process(writer, template, transformationTemplate);
    }
  });
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:18,代码来源:BaseDocumentationTest.java

示例5: assertSchema

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
public Stream<DynamicTest> assertSchema() {
  List<TestCase> tests = new ArrayList<>();
  of(tests, Schema.STRING_SCHEMA, Schema.STRING_SCHEMA, true);
  of(tests, Schema.STRING_SCHEMA, Schema.OPTIONAL_STRING_SCHEMA, false);
  of(tests, Schema.BYTES_SCHEMA, Decimal.schema(4), false);
  of(tests, null, null, true);
  of(tests, Schema.STRING_SCHEMA, null, false);
  of(tests, null, Schema.STRING_SCHEMA, false);

  return tests.stream().map(testCase -> dynamicTest(testCase.toString(), () -> {
    if (testCase.isEqual) {
      AssertSchema.assertSchema(testCase.expected, testCase.actual);
    } else {
      assertThrows(AssertionFailedError.class, () -> {
        AssertSchema.assertSchema(testCase.expected, testCase.actual);
      });
    }
  }));
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:21,代码来源:AssertSchemaTest.java

示例6: badData

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Stream<DynamicTest> badData() {
  List<Schema> schemas = Arrays.asList(
      Schema.INT8_SCHEMA,
      Schema.INT16_SCHEMA,
      Schema.INT32_SCHEMA,
      Schema.INT64_SCHEMA,
      Schema.FLOAT32_SCHEMA,
      Schema.FLOAT64_SCHEMA
  );

  return schemas.stream().map(schema ->
      dynamicTest(schema.type().name(), () -> {
        badDataTest(schema);
      })
  );
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:18,代码来源:JsonNodeTest.java

示例7: badData

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Stream<DynamicTest> badData() {
  List<Schema> schemas = Arrays.asList(
      Schema.INT8_SCHEMA,
      Schema.INT16_SCHEMA,
      Schema.INT32_SCHEMA,
      Schema.INT64_SCHEMA,
      Schema.FLOAT32_SCHEMA,
      Schema.FLOAT64_SCHEMA
  );

  return schemas.stream().map(schema ->
      dynamicTest(schema.type().name(), () -> {
        assertThrows(DataException.class, () -> {
          parser.parseString(schema, "asdf");
        });
      })
  );
}
 
开发者ID:jcustenborder,项目名称:connect-utils,代码行数:20,代码来源:StringParserTest.java

示例8: loadCases

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
@Override
public Stream<DynamicTest> loadCases(String param) throws IOException, URISyntaxException {
    return super.loadCases(param)
                .map(test -> DynamicTest.dynamicTest(test.getDisplayName(), () -> {
                    try {
                        ServletContextHandler servletContextHandler = new ServletContextHandler(ServletContextHandler.SESSIONS);
                        servletContextHandler.setContextPath("/");

                        // CXF Servlet
                        ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet());
                        cxfServletHolder.setInitParameter("jaxrs.serviceClasses", TestServerResource.class.getName());
                        servletContextHandler.addServlet(cxfServletHolder, "/*");


                        server = new Server(4442);
                        server.setHandler(servletContextHandler);
                        server.start();

                        Log.setLog(new StdErrLog());

                        test.getExecutable().execute();
                    } finally {
                        try {
                            server.stop();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }));
}
 
开发者ID:MegafonWebLab,项目名称:histone-java2,代码行数:32,代码来源:HttpTranslatorTest.java

示例9: statusEffectsExpireAfterDuration

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
@DisplayName("expires after the duration of ")
Stream<DynamicTest> statusEffectsExpireAfterDuration() {

    return IntStream.range(1, 4).mapToObj(duration ->
            dynamicTest(duration + " moves of the affected bot", () -> {
                Effect effect = createEffectFactoryFor(anyBot(),
                        duration, NoEffect.class).newInstance();
                Bot target = aBot().withStatusEffects(effect).build();

                for (int i = 0; i < duration; i++) {
                    assertFalse(effect.isExpired(), "Effect should not expire after " + i + " moves");
                    target.applyEffects();
                }
                assertTrue(effect.isExpired());
            }));

}
 
开发者ID:bkimminich,项目名称:kata-botwars,代码行数:19,代码来源:EffectTest.java

示例10: testAllPbeTypes

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Iterable<DynamicTest> testAllPbeTypes() throws Exception {

	List<DynamicTest> tests = new ArrayList<>();

	for (PrivateKey privateKey : privateKeys()) {
		for (OpenSslPbeType pbeType : OpenSslPbeType.values()) {
			tests.add(dynamicTest("test " + pbeType.name() + "/" + privateKey.getClass().getSimpleName(), () -> {
				byte[] encKey = OpenSslPvkUtil.getEncrypted(privateKey, pbeType, PASSWORD).getBytes();
				assertEquals(privateKey, OpenSslPvkUtil.loadEncrypted(new ByteArrayInputStream(encKey), PASSWORD));
				assertEquals(ENC_OPENSSL_PVK, CryptoFileUtil.detectFileType(new ByteArrayInputStream(encKey)));
			}));
		}
	}

	return tests;
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:18,代码来源:OpenSslPvkUtilTest.java

示例11: Should_Return_All_Permutations

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Stream<DynamicTest> Should_Return_All_Permutations() throws NoSuchFieldException {
    final Field perm1A = fieldFromPermutation1Class("a");
    final Field perm1B = fieldFromPermutation1Class("b");
    final Field perm2A = fieldFromPermutation2Class("a");
    final Field perm2B = fieldFromPermutation2Class("b");
    final Field perm2C = fieldFromPermutation2Class("c");

    final TestCase testCase1 = new TestCase(Permutation1.class,
                                            newArrayList(newArrayList(perm1A),
                                                         newArrayList(perm1B),
                                                         newArrayList(perm1A, perm1B)));
    final TestCase testCase2 = new TestCase(Permutation2.class, newArrayList(newArrayList(perm2A),
                                                                             newArrayList(perm2B),
                                                                             newArrayList(perm2C),
                                                                             newArrayList(perm2A, perm2B),
                                                                             newArrayList(perm2A, perm2C),
                                                                             newArrayList(perm2B, perm2C),
                                                                             newArrayList(perm2A, perm2B, perm2C)));
    return Stream.of(testCase1, testCase2)
                 .map(value -> dynamicTest(getDefaultDisplayName(value), Should_Return_All_Permutations(value)));
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:23,代码来源:FieldUtilsTest.java

示例12: Should_Throw_Exception_When_Setter_Was_Not_Found

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Stream<DynamicTest> Should_Throw_Exception_When_Setter_Was_Not_Found() throws NoSuchFieldException {
    final Field fieldA = field(Setters.class, "a");
    final Field fieldB = field(Setters.class, "b");
    final Field fieldC = field(Setters.class, "c");
    final Field fieldD = field(Setters.class, "d");
    final Field fieldF = field(Setters.class, "f");
    final Field fieldG = field(Setters.class, "g");

    return Stream.of(fieldA,
                     fieldB,
                     fieldC,
                     fieldD,
                     fieldF,
                     fieldG)
                 .map(value -> dynamicTest(getDefaultDisplayName(value),
                                           Should_Throw_Exception_When_Setter_Was_Not_Found(value)));
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:19,代码来源:MethodUtilsTest.java

示例13: Should_Throw_Exception_When_Getter_Was_Not_Found

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Stream<DynamicTest> Should_Throw_Exception_When_Getter_Was_Not_Found() throws NoSuchFieldException {
    final Field fieldA = field(Getters.class, "a");
    final Field fieldB = field(Getters.class, "b");
    final Field fieldD = field(Getters.class, "d");
    final Field fieldE = field(Getters.class, "e");
    final Field fieldF = field(Getters.class, "f");
    final Field fieldG = field(Getters.class, "g");

    return Stream.of(fieldA,
                     fieldB,
                     fieldD,
                     fieldE,
                     fieldF,
                     fieldG)
                 .map(value -> dynamicTest(getDefaultDisplayName(value),
                                           Should_Throw_Exception_When_Getter_Was_Not_Found(value)));
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:19,代码来源:MethodUtilsTest.java

示例14: Should_Change_Array_Value

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Stream<DynamicTest> Should_Change_Array_Value() {
    return Stream.of("a_int",
                     "a_char",
                     "a_float",
                     "a_double",
                     "a_boolean",
                     "a_byte",
                     "a_short",
                     "a_long",
                     "a_Int",
                     "a_Char",
                     "a_Float",
                     "a_Double",
                     "a_Boolean",
                     "a_Byte",
                     "a_Short",
                     "a_Long",
                     "a_object_null",
                     "a_object",
                     "a_a")
                 .map(fieldName -> dynamicTest(getDefaultDisplayName(fieldName),
                                               Should_Change_Array_Value(fieldName)));
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:25,代码来源:ArrayValueChangerTest.java

示例15: Should_Return_True_Or_False_Whether_Can_Change_Or_Not

import org.junit.jupiter.api.DynamicTest; //导入依赖的package包/类
@TestFactory
Stream<DynamicTest> Should_Return_True_Or_False_Whether_Can_Change_Or_Not() throws NoSuchFieldException {
    return Stream.of(new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_int"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_char"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_float"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_double"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_boolean"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_byte"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_short"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_long"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_Int"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_Char"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_Float"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_Double"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_Boolean"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_Byte"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_object_null"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_object"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a_a"), true),
                     new CanChangeCase(ClassContainingArrays.class.getDeclaredField("a"), false))
                 .map(value -> dynamicTest(getDefaultDisplayName(value.field.getName()),
                                           Should_Return_True_Or_False_Whether_Can_Change_Or_Not(value)));
}
 
开发者ID:sta-szek,项目名称:pojo-tester,代码行数:24,代码来源:ArrayValueChangerTest.java


注:本文中的org.junit.jupiter.api.DynamicTest类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。