【问题标题】:Unable to suppress excessive logs from scalatest-maven-plugin无法抑制来自 scalatest-maven-plugin 的过多日志
【发布时间】:2018-07-31 13:52:26
【问题描述】:

背景

当我从 maven 运行 scala 测试时,我面临来自默认 Logger 的过多日志记录,因为它没有使用正确的日志记录定义在类路径上拾取 logback.xml

所以我的 maven 配置相当通用(根据 scalatest-maven-plugin 文档) 看起来像这样

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
        <!-- enable scalatest -->
        <plugin>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest-maven-plugin</artifactId>
            <version>1.0</version>
            <configuration>
                <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                <junitxml>.</junitxml>
                <filereports>MyProj_TestSuite.txt</filereports>
                <forkMode>never</forkMode>
            </configuration>
            <executions>
                <execution>
                    <id>test</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

我的 src/main/resources 中有一个 logback.xml,它被复制到目标/类

到目前为止我尝试过的事情

花了一整天的时间来弄清楚为什么没有被选中 -- 使用以下配置可选条目

<runpath>
${project.basedir}/target/classes
</runpath>

<systemProperties>
<logback.configurationFile> ${project.basedir}/src/main/resources/logback.xml</logback.configurationFile>
</systemProperties>

<argLine>
-Dlogback.configurationFile=src/main/resources/logback.xml
</argLine>

如果我从 ${project.basedir} 像这样(从命令行)运行它

mvn test -Dlogback.configurationFile=./src/test/resources/logback.xml

有效

我在堆栈上查看过类似的问题,甚至尝试添加此问题

    <build>
        <testResources>
            <testResource>
                <directory>${project.basedir}/target/classes</directory>
            </testResource>
            <testResource>
                <directory>${project.basedir}/src/test/resources</directory>
            </testResource>
        </testResources>
 </build>

这不起作用 - 我认为这是因为我正在使用具有 own configuration block. 的 scala-maven-test 插件

任何关于如何从 pom.xml 中执行此操作的帮助将不胜感激。

【问题讨论】:

    标签: logback scalatest-maven-plugin


    【解决方案1】:

    尝试拥有/src/test/resources/logback-test.xml logback 配置文件。 它适用于我的 scalatest-maven-plugin 2.0.2 版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-31
      • 2017-11-02
      • 2017-04-04
      相关资源
      最近更新 更多