Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide ability to reload .properties on runtime #6

Closed
iKozzz opened this issue Nov 9, 2016 · 19 comments
Closed

Provide ability to reload .properties on runtime #6

iKozzz opened this issue Nov 9, 2016 · 19 comments

Comments

@iKozzz
Copy link

iKozzz commented Nov 9, 2016

I would like to update listener with new properties values before tests are executed.

Basically i need to create reportportal.properties according to starting suite and then update ReportPortalTestNGListener (in my case) with new information.
Currently this is unable because listener will initialize itself on TestNG framework start.

I know that i can pass environment variables thru command line, but it's not the case for me.
My idea is to keep all configuration inside my framework and require only necessary command line parameters. For example -Dclient=SomeClientID is a keyword to setup all the required data for suite.

@avarabyeu
Copy link
Member

@iKozzz we can provide method for completely re-initialize guice app context. Will it work for you?

@avarabyeu avarabyeu added this to the 2.7 milestone Nov 22, 2016
@iKozzz
Copy link
Author

iKozzz commented Nov 28, 2016

Yeah, we can run this method on @BeforeSomething

@DzmitryHumianiuk
Copy link
Member

@avarabyeu up?

@DzmitryHumianiuk DzmitryHumianiuk modified the milestones: 3.0, 2.7, 3.1 Mar 20, 2017
@avarabyeu
Copy link
Member

Added in 3.0. Additional details on making this will be provided in documentation

@Lalesia
Copy link

Lalesia commented Jul 29, 2017

Hi everyone!
Where I can find in documetation this approach?
I really need it right now for project with a lot of modules and projects, so it would be great to change property file in runtime. Thanks

@avarabyeu
Copy link
Member

@Lalesia properties are being loaded from here: PropertiesLoader

If i'd like to override properties you can use jvm\env vars or replace\override it on the code level in Configuration Module

Example of extending TestNG Listener can be found here

@DzmitryHumianiuk DzmitryHumianiuk modified the milestones: 3.3, 3.2 Aug 23, 2017
@iKozzz
Copy link
Author

iKozzz commented Sep 12, 2017

Way too odd. I was expecting to see something like
PropertiesLoader.add("my_custom_parts.properties");
or
PropertiesLoader.reload();

usecase1 - I'm using ReportPortalTestNGListener and I want too change Launch name prior to test start but after framework initialization.
usecase2 - I'm using ReportPortalTestNGListener and I want too add more tags after framework initialization

@KunalShokeen432
Copy link

KunalShokeen432 commented Jul 11, 2019

@DzmitryHumianiuk I have written below snippet in 'BeforeSuite' for setting launch name in reportporttal.properties.

PropertiesConfiguration conf = new PropertiesConfiguration("src/main/resources/reportportal.properties");
			conf.setProperty("rp.launch", "Kunal");
			conf.save();

It is set successfully but after Reportportal listener is initialized in suite.xml file.
Is there a way to set it prior Reportportal listener initialization ?

@DzmitryHumianiuk
Copy link
Member

@iKozzz can you comment on above as well?

@ghost
Copy link

ghost commented Jul 17, 2019

You can achieve using Environment variables. Its working fine for me

@ghost
Copy link

ghost commented Jul 17, 2019

@DzmitryHumianiuk I have written below snippet in 'BeforeSuite' for setting launch name in reportporttal.properties.
PropertiesConfiguration conf = new PropertiesConfiguration("src/main/resources/reportportal.properties");
conf.setProperty("rp.launch", "Kunal");
conf.save();
It is set successfully but after Reportportal listener is initialized in suite.xml file.
Is there a way to set it prior Reportportal listener initialization ?

Create environment variables or pass the value from command line. I am passing it from maven command:
mvn -U -fn -Dsurefire.suiteXmlFiles=D:\testng\webdriver\singleTest.xml -Drp.launch=MOH -Drp.enable=true clean test

@KunalShokeen432
Copy link

@mohdsgithub Great thanks it works for me too. As it seems, it will override the values present in reportportal.properties if provided via command line ? :)

@iKozzz
Copy link
Author

iKozzz commented Jul 17, 2019

we came up with custom runner so we can play with properties prior to ReportPortal.listener start

@ghost
Copy link

ghost commented Jul 19, 2019

@mohdsgithub Great thanks it works for me too. As it seems, it will override the values present in reportportal.properties if provided via command line ? :)
awesome!!
Also I stored 'rp.enable' parameter value passed from command line. This will enable us to decide whether to send screen shot attachment to RP or not in case of test failure

@KunalShokeen432
Copy link

Can anyone of you also look at the issue tagged with RP usage with Selenium Grid.

@ghost
Copy link

ghost commented Jul 20, 2019

@KunalShokeen432 I am using RP with my selenium testng framework.
What exactly r u looking for

@acdurai
Copy link

acdurai commented Nov 18, 2019

Hi @DzmitryHumianiuk ,
I'm using selenium with JUNIT 4.12 framework, I would like to update the reportportal.properties file before the Reportportal listener is getting initialized .
Please help me on this

@DzmitryHumianiuk
Copy link
Member

@acdurai join our community in slack
https://reportportal-slack-auto.herokuapp.com/

and ask in #agent_java channel for help

@acdurai
Copy link

acdurai commented Nov 19, 2019

@DzmitryHumianiuk thank you so much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants