Open skhandekar1 opened 3 years ago
I tried updating the serenity.properties file in @BeforeClass, but the properties file is not getting picked up by junit and it still uses the old properties. Any ideas how to solve this problem?
private static FileInputStream fis = null;
private static String propFile = "serenity.properties";
@BeforeClass
public static void init() {
try {
FileInputStream in = new FileInputStream(propFile);
Properties props = new Properties();
props.load(in);
in.close();
FileOutputStream out = new FileOutputStream(propFile);
props.setProperty("appium.dontStopAppOnReset", "true");
props.store(out, null);
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
If you want to apply only for certain test scripts. It should not set the configuration in the @BeforeClass because this annotation will run first for all class.
For this goals: you should create an annotation that is used for each certain test.
The idea is like that
@AppiumCap(dontStopAppOnReset=true)
@Test
public void your_test(){ ... }
Could you please explain how to create such an annotation. My problem is that Serenity bdd, it is going to look at the code and already set the parameter as false when it doesnt find it in the propeties, so how can i set it to true through the annotation? I trued System.setProperty and it does not work as Serenity bdd does now allow change in properties. So your method looks interesting, just i am not sure how to create such an annotation. Could you please explain? Thank you!
The @BeforeClass
method it needs to be static and what I have done is to use
System.setProperty("webdriver.driver", "remote");
@BeforeClass
will run before the test suite so if you had 2 testsuite classes each with a different @BeforeClass
method to set that property to what you need. it should work
I am running Serenity with appium and junit. I want to update the appium.dontStopAppOnReset = true only for certain test scripts. Is it possible to do this through junit? My junit script looks as follows:
package com.tp.tp397.Procedure1_ORSession;
//@RunWith(SerenityRunner.class)
//@FixMethodOrder(MethodSorters.NAME_ASCENDING) @WithTags({ @WithTag(type = "TP", name = "TP-000397") }) @RunWith(SerenityRunner.class) public class TP397_P1_S06 {
}