org.junit.jupiter.api.Test.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(5.6k)|赞(0)|评价(0)|浏览(169)

本文整理了Java中org.junit.jupiter.api.Test.<init>()方法的一些代码示例,展示了Test.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Test.<init>()方法的具体详情如下:
包路径:org.junit.jupiter.api.Test
类名称:Test
方法名:<init>

Test.<init>介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

@Test
void autowiredParameterOfList(@Autowired List<Person> peopleParam) {
  assertNotNull(peopleParam, "list of people should have been @Autowired by Spring");
  assertEquals(2, peopleParam.size(), "Number of people in context");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@DisabledOnMac
void disabledIfWithSpelOsCheckInCustomComposedAnnotation() {
  assertFalse(System.getProperty("os.name").contains("Mac"), "This test must be disabled on Mac OS");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
void autowiredParameterThatDoesNotExistAsJavaUtilOptional(
    @Autowired Optional<Number> number) {
  assertNotNull(number, "Optional number should have been @Autowired by Spring");
  assertFalse(number.isPresent(),
      "Value of Optional number should not be 'present'");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
void applicationContextInjected() {
  assertNotNull(applicationContext, "ApplicationContext should have been injected by Spring");
  assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@DisabledIf("true")
void disabledIfWithStringTrue() {
  fail("This test must be disabled");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@DisabledIf(expression = "#{@stringTrueBean}", loadContext = true)
void disabledIfWithSpelStringTrueBean() {
  fail("This test must be disabled");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@DisabledIf("TrUe")
void disabledIfWithStringTrueIgnoreCase() {
  fail("This test must be disabled");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@DisabledIf("#{T(Boolean).TRUE}")
void disabledIfWithSpelBoolean() {
  fail("This test must be disabled");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@EnabledIf(expression = "${foo}", loadContext = true)
void enabledIfWithPropertyPlaceholder() {
  fail("This test must be disabled");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@EnabledIf("   #{T(Boolean).FALSE}   ")
void enabledIfWithSpelBooleanWithSurroundingWhitespace() {
  fail("This test must be disabled");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@EnabledIf("#{'fal' + 'se'}")
void enabledIfWithSpelStringConcatenation() {
  fail("This test must be disabled");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@EnabledIf("#{1 + 2 == 4}")
void enabledIfWithSpelArithmeticComparison() {
  fail("This test must be disabled");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
void autowiredParameterWithExplicitQualifier(@Qualifier("wally") Person person) {
  assertNotNull(person, "Wally should have been @Autowired by Spring");
  assertEquals("Wally", person.getName(), "Person's name");
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * NOTE: Test code must be compiled with "-g" (debug symbols) or "-parameters" in order
 * for the parameter name to be used as the qualifier; otherwise, use
 * {@code @Qualifier("wally")}.
 */
@Test
void autowiredParameterWithImplicitQualifierBasedOnParameterName(@Autowired Person wally) {
  assertNotNull(wally, "Wally should have been @Autowired by Spring");
  assertEquals("Wally", wally.getName(), "Person's name");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
void genericApplicationContextInjectedIntoMethod(
    GenericApplicationContext applicationContext) {
  assertNotNull(applicationContext,
      "GenericApplicationContext should have been injected by Spring");
  assertEquals(this.dilbert, applicationContext.getBean("dilbert", Person.class));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
void junitAndSpringMethodInjectionCombined(@Autowired Cat kittyCat, TestInfo testInfo,
    ApplicationContext context, TestReporter testReporter) {
  assertNotNull(testInfo, "TestInfo should have been injected by JUnit");
  assertNotNull(testReporter, "TestReporter should have been injected by JUnit");
  assertNotNull(context, "ApplicationContext should have been injected by Spring");
  assertNotNull(kittyCat, "Cat should have been @Autowired by Spring");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
default void autowiredParameterWithGenericBean(@Autowired C character) {
  assertNotNull(character, "Character should have been @Autowired by Spring");
  assertEquals(getExpectedName(), character.getName(), "character's name");
}

代码示例来源:origin: spring-projects/spring-framework

@Test
void notDisabledWithDefaultReason() {
  assertResult(condition.evaluateExecutionCondition(buildExtensionContext("neverDisabledWithDefaultReason")), false, endsWith(
    "neverDisabledWithDefaultReason() is enabled because @DisabledIf(\"false\") did not evaluate to true"));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
void disabledWithDefaultReason() {
  assertResult(condition.evaluateExecutionCondition(buildExtensionContext("defaultReason")), true,
    endsWith("defaultReason() is disabled because @DisabledIf(\"#{1 + 1 eq 2}\") evaluated to true"));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
void springMvcTest(WebApplicationContext wac) throws Exception {
  webAppContextSetup(wac).build()
    .perform(get("/person/42").accept(MediaType.APPLICATION_JSON))
    .andExpect(status().isOk())
    .andExpect(jsonPath("$.name", is("Dilbert")));
}

相关文章

Test类方法