如何配置Cucumber JVM + Logging appender?

时间:2017-05-11 23:09:48

标签: reportportal

我正在使用
agent-java-cucumber作为代理(和客户端?)
也许我应该使用reportportal-java作为客户端(尝试没有成功)
logger-java-log4j as logging appender

现在我只从ScenarioReporter获取日志(场景,步骤等)
report portal screenshot
logger.debug("某些东西")在RP中不可见。 我错过了配置中的一些东西吗?
转轮

package com.example.rp.runner;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        glue = {"com.example.rp.steps"},
        features = "src/test/resources/features",
        tags = "@logging",
        plugin = {"com.epam.reportportal.cucumber.ScenarioReporter", "pretty", "html:target/cucumber"}
)
public class CucumberRunner{
}

这是我的pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example.rp</groupId>
    <artifactId>report-portal-logging</artifactId>
    <version>1.0-SNAPSHOT</version>

    <repositories>
        <repository>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <id>bintray-epam-reportportal</id>
            <name>bintray</name>
            <url>http://dl.bintray.com/epam/reportportal</url>
        </repository>
    </repositories>


    <dependencies>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.8.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.8.2</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>20.0</version>
        </dependency>

        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-junit</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>info.cukes</groupId>
            <artifactId>cucumber-java</artifactId>
            <version>1.2.5</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.8.8</version>
        </dependency>
        <dependency>
            <groupId>com.epam.reportportal</groupId>
            <artifactId>client-java-core</artifactId>
            <version>2.7.0</version>
        </dependency>
        <dependency>
            <groupId>com.epam.reportportal</groupId>
            <artifactId>agent-java-cucumber</artifactId>
            <version>2.6.1</version>
        </dependency>
        <dependency>
            <groupId>com.epam.reportportal</groupId>
            <artifactId>logger-java-log4j</artifactId>
            <version>3.0.1</version>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.7.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <includes>
                                <include>**/CucumberRunner.java</include>
                            </includes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

项目here

1 个答案:

答案 0 :(得分:2)

您发布的示例的主要问题是您使用2x代客户端和3x代日志记录appender。 Here is example of how to configure cucumber client 要设置日志记录,您需要执行following steps