【问题标题】:Reportportal with testng - how to set launch name during run time带有 testng 的 Reportportal - 如何在运行时设置启动名称
【发布时间】:2018-02-21 07:06:23
【问题描述】:

我正在寻找一种在 testng 运行期间设置启动名称的方法。这在配置(rp.launch)中设置。我需要为每个 testng 运行设置一个自定义启动名称。我正在使用 agent-java-testng:4.0.0-BETA-1

我尝试了建议的替代方法,但找不到此处提到的类 - ConfigurationModule & TestNGAgentModule: https://github.com/reportportal/agent-java-testNG

public class MyListener extends BaseTestNGListener {
    public MyListener() {
        super(Injector.create(Modules.combine(Modules.override(new ConfigurationModule())
                        .with(new Module() {
                            @Override
                            public void configure(Binder binder) {
                                Properties overrides = new Properties();
                                overrides.setProperty(ListenerProperty.UUID.getPropertyName(), "my crazy uuid");
                                PropertiesLoader propertiesLoader = PropertiesLoader.load();
                                propertiesLoader.overrideWith(overrides);
                                binder.bind(PropertiesLoader.class).toInstance(propertiesLoader);
                            }
                        }),
                new ReportPortalClientModule(),
                new TestNGAgentModule()
        )));
    }
}

我有一个要添加到 TestNG 的自定义侦听器 (ReportPortalTestNGListener)

TestNG myTestNG = new TestNG(); XmlSuite 套件 = 新 XmlSuite(); ... 列出 mySuites = new ArrayList(); mySuites.add(suite);

        ReportPortalTestNGListener listener = new ReportPortalTestNGListener();


        myTestNG.addListener((Object)listener);
        myTestNG.setUseDefaultListeners(false);

        // add test suite
        myTestNG.setXmlSuites(mySuites);
        myTestNG.run();

【问题讨论】:

    标签: testng reportportal


    【解决方案1】:

    不幸的是,由于格式的原因,问题的描述很难理解。 一般来说,有两个选项可以在运行时设置启动名称: 1) 使用环境/JVM 变量。您应该了解,应该在初始化 ReportPortal 的侦听器之前设置变量。 2) 扩展 ReportPortal 侦听器并将启动时间传递给请求构建器。请使用以下snippet as example

    【讨论】:

    • 为 ReportPortal 设置环境变量存在挑战。
    • 为 ReportPortal 设置环境变量有一个挑战:它们都有一个“.” (dot) 在 linux 环境中的环境变量中不受支持。例如: rp.endpoint 、 rp.uuid 、 rp.project 。它们在变量名中都有点。代码的原始帖子来自github.com/reportportal/agent-java-testNG 中列出的示例。我无法让它工作:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-15
    • 2012-07-30
    • 2021-12-22
    • 1970-01-01
    • 2019-07-11
    • 2019-07-23
    • 1970-01-01
    相关资源
    最近更新 更多