使用Java + TestNG或Java + Log4j配置Reportportal

问题描述 投票:0回答:2

一直在尝试使用示例项目配置Reportportal。已完成以下步骤:

    1.Start a Docker and get the reportporal page up and running.
    2.In the Java project, added the bintray repository, java-agent-testng, logger-java-log4j dependencies.
    3.Included log4j.properties file in the project and also the log4j.appender line for reprortportal
log4j.appender.reportportal=com.epam.ta.reportportal.log4j.appender.ReportPortalAppender
log4j.appender.reportportal.layout=org.apache.log4j.PatternLayout 
log4j.appender.reportportal.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p (%F:%L) - %m%n
    4.Included log4j info lines for one of the @Test methods.
    5.Ran the Test script and made sure the log info line is seen on the console.
    6.However, the reportportal dashboard still shows "No Results Found"
    7.Also, added the following line for the Test Method.
@Listeners({ReportPortalTestNGListener.class})
    8. This threw an exception with Jackson.

我心中想到几个问题:

    1.Do we need both TestNG and Log4j to integrate with reportportal or just one of them is fine.
    2. With the above steps carried out, is there anything that has been missed. Why am I not seeing data on my reportportal dashboard.
log4j testng reporting test-reporting reportportal
2个回答
1
投票

我只使用testNG集成来做到这一点。我们确实有log4j,但不需要在RP中发布测试。但是,我没有任何截图或附件。我认为这是log4j集成。


1
投票

@Chethan Swaroop TestNG集成将testStartedtestEnded发送到ReportPortal。

这将有助于表示RP中的测试用例和状态的结构。

Log4J集成(logger appender)将日志输出转发到RP服务器,此时将日志行与活动测试用例相关联。

你可以只有testNG集成,没有日志(log4j),但你没有log4j,没有测试引擎集成(在你的情况下是testNG)

请尝试使用本地ReportPortal实例的示例:

https://github.com/reportportal/example-java-TestNG/tree/master/logback/src/main/java/com/epam/rp/tests

© www.soinside.com 2019 - 2024. All rights reserved.