I am looking for a way to set launch name during testng run. This is otherwise set in configuration (rp.launch). I need to set a custom launch name for every testng run. I am using agent-java-testng:4.0.0-BETA-1
I have tried the suggested alternative way but cannot locate the classes that are mentioned here - 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()
)));
}
}
I have a custom listener (ReportPortalTestNGListener) that I am adding to TestNG
TestNG myTestNG = new TestNG(); XmlSuite suite = new XmlSuite(); ... List 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();
Unfortunately, the description of issue is pretty difficult to understand due to formatting. Generally speaking, there are two options to set launch name on runtime: 1) Use environment/JVM variables. You should understand that variable should be set before ReportPortal's listener is initialized. 2) Extend ReportPortal listener and pass launch time right to the request builder. Please, use the following snippet as example