When running mvn verify
I am getting below message:
I already put the log4j2.xml
under src/test/resources
(but not in src/main/resources
because I do not want it to ship with actual app) as suggested here to no avail.
The HTML report is generated, the log file is written, and the build is successful as seen above. I am unsure where the error is coming from.
log4j2.xml:
<?xml version="1.0" encoding="UTF-8"?> <Configuration status="WARN"> <Properties> <Property name="logPath">target/cucumber-logs</Property> </Properties> <Appenders> <RollingFile name="fileLogger" fileName="${logPath}/cucumber-log.log" filePattern="${logPath}/cucumber-log_%d{yyyy-MM-dd}.log"> <PatternLayout> <pattern>[%-5level] %d{HH:mm:ss.SSS} %logger{36}.%M() - %msg%n </pattern> </PatternLayout> <Policies> <OnStartupTriggeringPolicy /> <TimeBasedTriggeringPolicy interval="1" modulate="true" /> </Policies> </RollingFile> <Console name="console" target="SYSTEM_OUT"> <PatternLayout> <pattern>[%-5level] %d{HH:mm:ss.SSS} %logger{36}.%M() - %msg%n </pattern> </PatternLayout> </Console> </Appenders> <Loggers> <Root level="TRACE" additivity="false"> <AppenderRef ref="console" /> <AppenderRef ref="fileLogger" /> </Root> </Loggers> </Configuration>
pom.xml:
<dependencies> <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server --> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> <version>${selenium.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.paulhammant/ngwebdriver --> <dependency> <groupId>com.paulhammant</groupId> <artifactId>ngwebdriver</artifactId> <version>${ngwebdriver.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-junit --> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-testng</artifactId> <version>${cucumber.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/info.cukes/cucumber-picocontainer --> <dependency> <groupId>io.cucumber</groupId> <artifactId>cucumber-picocontainer</artifactId> <version>${cucumber.version}</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core --> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>2.10.0</version> <scope>test</scope> </dependency> <!-- https://mvnrepository.com/artifact/com.itextpdf/itextpdf --> <dependency> <groupId>com.itextpdf</groupId> <artifactId>itextpdf</artifactId> <version>5.5.13</version> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml --> <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi-ooxml</artifactId> <version>3.17</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.7.0</version> <configuration> <source>${java.version}</source> <target>${java.version}</target> </configuration> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.20.1</version> <configuration> <includes> <include>**/*Runner.java</include> </includes> <testFailureIgnore>true</testFailureIgnore> <reportsDirectory>./target/test-output/${timestamp}</reportsDirectory> </configuration> </plugin> <plugin> <groupId>net.masterthought</groupId> <artifactId>maven-cucumber-reporting</artifactId> <version>3.15.0</version> <executions> <execution> <id>execution</id> <phase>verify</phase> <goals> <goal>generate</goal> </goals> <configuration> <projectName>Simply Do - Balance Projector</projectName> <outputDirectory>${project.build.directory}</outputDirectory> <jsonFiles> <param>${project.build.directory}/cucumber-generated-reports/cucumber-report.json</param> </jsonFiles> <parallelTesting>false</parallelTesting> </configuration> </execution> </executions> </plugin> </plugins> </build>
5 Answers
Answers 1
You use the latest Cucumber version 3.15.0 (at the time of writing this). Your problem was resolved as issue #675. There was a commit from a pull request meant to fix this problem, but probably you have to wait until the next version is released in order to profit from it - or build a snapshot version locally and see if it also fixes the problem for you.
Answers 2
According http://logging.apache.org/log4j/2.x/manual/configuration.html#AutomaticConfiguration adding log4j2.xml
to classpath should help.
If a JSON file cannot be located the XML ConfigurationFactory will try to locate log4j2.xml on the classpath.
So if you still get ERROR message problem not with your sources. It looks like problem in maven-cucumber-reporting
plugin. As described here http://maven.apache.org/guides/mini/guide-maven-classloading.html
Please note that the plugin classloader does neither contain the dependencies of the current project nor its build output.
If maven plugin cannot find any log4j configuration in its own classpath (which is not including your sources/resources) you will see error messages. So yes, the only solution wait for release with fix https://github.com/damianszczepanik/cucumber-reporting/issues/675
Answers 3
Run -> Run Configurations -> Classpath -> User entries -> Advanced Optiones -> Add Folders -> Then add your folder,in your case src/test/resources -> apply
It must work now :D
Answers 4
You are receiving this error because cucumber
or its dependencies are using log4j
for logging and since there is no log4j
configuration file so log4j
is printing such message.
If there is no log4j
configuration file, log4j
uses configuration similar to below -
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE Configuration> <Configuration status="warn" name="xml_configuration"> <Appenders> <Console name="consoleLogger" target="SYSTEM_OUT"> <PatternLayout pattern="[%level] %m%n" /> </Console> </Appenders> <Loggers> <Root level="error" additivity="false"> <appender-ref ref="consoleLogger" /> </Root> </Loggers> </Configuration>
Adding above configuration in /src/main/resources/log4j2.xml
will have same result as having no log4j2.xml
file.
Another way to try is to pass log4j2.xml
file to maven directly without putting it in project classpath. Something like below -
set MAVEN_OPTS="-Dlog4j.configurationFile=file:///path/to/log4j2.xml" mvn verify
Answers 5
according to their documentation, you can use 'joranConfigurator' and load the configuration from a specified file
0 comments:
Post a Comment