TestNG加载顺序

225 阅读1分钟

背景

我用SpringBoot + TestNG做接口测试,TestNG做数据驱动,希望能够把数据文件放到application.yml中配置。 可是,当我尝试用@Value去取文件路径/文件名的时候,抛出了个null。

image.png

探索

为什么无法用@Value获取application.yml中值呢?搜索了一下,最精炼的一个描述就是:

The way you are performing the injection of the property will not work, because the injection is done after the constructor is called.

image.png

image.png

toolsqa.com/selenium-we… www.ibm.com/developerwo…