0

嗨,我在一个项目中有一个模块,我试图从模块目录中运行它:

mvn 集成测试-PmyProps

在 pom

<properties>
                <user>admin</user>

</properties

在 src/test/resources/test.properties

 user=${user}

当我执行测试时,我得到user={user} instead of user=admin

如果我通过 intellij 或 eclipse 运行它,我对它没有任何问题,并且属性会被拾取吗?

是因为属性值被分配给目标目录吗?

这是类加载器:

InputStream testPropertiesInput = WebDriverConfiguration.class.getClassLoader().getResourceAsStream("smoke.properties");

我尝试将其设为“target/classes/smoke.properties”,但没有运气。

4

1 回答 1

1

首先,如果您有似乎适合您的单元测试,请简单地使用:

mvn 测试

此外,要过滤资源文件,您需要主动过滤

<build>
  <resources>
    <resource>
      <directory>...</directory>
      <filtering>true</filtering>
    </resource>
   ...
</build>
于 2012-11-28T13:53:32.363 回答