Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在JUnit 5下进行Spring引导测试,以解决YAML文件上外部化的缩进/分层属性_Java_Spring Boot_Junit5_Spring Boot Test - Fatal编程技术网

Java 如何在JUnit 5下进行Spring引导测试,以解决YAML文件上外部化的缩进/分层属性

Java 如何在JUnit 5下进行Spring引导测试,以解决YAML文件上外部化的缩进/分层属性,java,spring-boot,junit5,spring-boot-test,Java,Spring Boot,Junit5,Spring Boot Test,如何在JUnit 5下进行Spring启动测试解决YAML文件上外部化的缩进/分层属性? 我想编写测试来验证一些逻辑,这取决于: dottered.hierarchy.property属性在application test.ymlYAML文件中定义如下: 虚线: 层次结构: 属性:application-test.yml 测试用例失败,属性评估为null。我已锁定到spring boot 1.5.8.RELEASE,因此我正在使用。我创建了一个 @ExtendWith(SpringExtens

如何在
JUnit 5
下进行
Spring启动测试
解决YAML文件上外部化的缩进/分层属性?

我想编写测试来验证一些逻辑,这取决于:

dottered.hierarchy.property
属性在
application test.yml
YAML文件中定义如下:

虚线:
层次结构:
属性:application-test.yml
测试用例失败,属性评估为
null
。我已锁定到spring boot 1.5.8.RELEASE,因此我正在使用。我创建了一个

@ExtendWith(SpringExtension.class)
class PropertiesReolution_SO_IT {

    @Nested
    @TestPropertySource(locations = "classpath:application-test.yml")
    public class ViaYamlFile {

        @Autowired
        private Environment env;

        @Test
        void testGetDottedHierarchicalProperty() throws Exception {
            final String key = "dotted.hierarchical.property";
            assertNotNull(this.env.getProperty(key));
            assertEquals("application-test.yml", this.env.getProperty(key));
        }
    }

}