并行执行黄瓜硒测试时的回退配置错误

时间:2019-07-19 00:03:11

标签: java spring-boot cucumber logback

我用Cucumber-Selenium-SpringBoot-Junit-maven创建了一个自动化测试框架。我正在使用logback作为我的日志记录框架。当我在单线程中执行测试时,它永远不会报告任何错误。但是当我并行执行测试时,logback报告错误并且仅启动一项功能测试,而其他线程功能测试全部失败。

这是我的logback-spring.xml文件:

<?xml version="1.0" encoding="UTF-8"?>
<configuration  scan="true" scanPeriod="60 seconds" debug="false">
    <contextName>EssaLog</contextName>
    <property name="logPath" value="src/main/log/" />
    <!--Output to console-->
    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
        <encoder>
            <pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <!--Output to file-->
    <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--        <file>${logPath}EssaLog.log</file>-->
        <!-- Daily generate log file -->
        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
            <!--Log output pattern: daily -->
            <fileNamePattern>${logPath}essa_%d{yyyy-MM-dd_HHmm}.log</fileNamePattern>
            <!--Delete log after 30 days-->
            <maxHistory>30</maxHistory>
            <!--Max size of log file-->
            <totalSizeCap>10MB</totalSizeCap>
        </rollingPolicy>
        <immediateFlush>true</immediateFlush>
        <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
            <!--Output format:%d %thread %-5level %msg %n-->
            <pattern>%d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n</pattern>
            <!-- encode -->
            <charset>UTF-8</charset>
        </encoder>
    </appender>

    <root level="DEBUG">
        <appender-ref ref="console" />
        <appender-ref ref="file" />
    </root>
    <!--TRACE < DEBUG < INFO < WARN < ERROR < FATAL-->
    <!-- Package logging -->
    <logger name="EssaApplicationTests" level="DEBUG" additivity="false"/>

    <!-- Define multiple environment -->
    <springProfile name="ST">
        <logger name="EssaApplicationTests" level="DEBUG" />
    </springProfile>
    <springProfile name="SIT">
        <logger name="EssaApplicationTests" level="INFO" />
    </springProfile>

</configuration>

错误: 引起原因:java.lang.IllegalStateException:检测到Logback配置错误:

ERROR in ch.qos.logback.core.rolling.RollingFileAppender[file] - 'FileNamePattern' option has the same value "src/main/log/essa_%d{yyyy-MM-dd_HHmm}.log" as that given for appender [file] defined earlier.
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[file] - Collisions detected with FileAppender/RollingAppender instances defined earlier. Aborting.
ERROR in ch.qos.logback.core.rolling.RollingFileAppender[file] - For more information, please visit http://logback.qos.ch/codes.html#earlier_fa_collision

请注意,此错误仅在并行执行测试时发生。 谁能帮我解决这个问题?欢迎任何输入。预先感谢。

0 个答案:

没有答案