本文整理了Java中org.junit.jupiter.api.Test
类的一些代码示例,展示了Test
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Test
类的具体详情如下:
包路径:org.junit.jupiter.api.Test
类名称:Test
暂无
代码示例来源:origin: spring-projects/spring-framework
@Test
void autowiredParameterThatDoesNotExistButIsNotRequired(
@Autowired(required = false) Number number) {
assertNull(number,
"Non-required number should have been @Autowired as 'null' by Spring");
}
代码示例来源: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
void valueParameterFromDefaultValueForPropertyPlaceholder(@Value("${bogus:false}") Boolean defaultValue) {
assertNotNull(defaultValue, "Default value should have been injected via @Value by Spring");
assertEquals(false, defaultValue, "default value");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
void valueParameterFromSpelExpression(@Value("#{@dilbert.name}") String name) {
assertNotNull(name, "Dilbert's name should have been injected via SpEL expression in @Value by Spring");
assertEquals("Dilbert", name, "name from SpEL expression");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
void propertyPlaceholderInjected() {
assertNotNull(this.enigma, "Enigma should have been injected via @Value by Spring");
assertEquals(Integer.valueOf(42), this.enigma, "enigma");
}
代码示例来源:origin: spring-projects/spring-framework
@Test
void valueParameterFromDefaultValueForPropertyPlaceholder(
@Value("${bogus:false}") Boolean defaultValue) {
assertNotNull(defaultValue,
"Default value should have been injected via @Value by Spring");
assertEquals(false, defaultValue, "default value");
}
代码示例来源: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 nestedTest() throws Exception {
assertEquals("foo", foo);
assertEquals("bar", bar);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
void nestedTest() throws Exception {
// In contrast to nested test classes running in JUnit 4, the foo
// field in the outer instance should have been injected from the
// test ApplicationContext for the outer instance.
assertEquals("foo", foo);
assertEquals("bar", bar);
}
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@DisabledIf(" true ")
void disabledIfWithStringTrueWithSurroundingWhitespace() {
fail("This test must be disabled");
}
内容来源于网络,如有侵权,请联系作者删除!