I am using Serenity bdd with junit 4 for running appium on native Android app. After each @Test run my app shutsdown. I have tried to search a lot on google to find how to avoid the shutdown. Problem is my tests are so minor (like clicking on up button and checking if the required value increased by a specific amount, etc) that I do not need or want to shutdown app between test run. Now I could have added all the tests to a single @Test, but I need to setup a test listener to listen to the events and write to a csv report that we have to submit to FDA for approval. Right now I am grouping my similar tests into the @Test, but I still need different @Tests so that the testID’s get logged as a separate test id in the reports.
My question is how can I prevent the shutdown from happening. I have tried appium.noReset to true but that does not work. I have added my Serenity.properties and junit test below for your reference:
#webdriver.timeouts.implicitlywait = 1000
#Note: Commented out ‘implicitlywait’ to avoid use of implicit wait in conjunction with explicit wait
#TODO: Check stability of TP run; what is default behavior when implicitlywait is not set?
webdriver.driver = appium
appium.platformName = Android
appium.platformVersion = 10.0
#Replace deviceName and udid with your S6 Tablet's Serial Number
appium.deviceName = HGFJGKHLJ
appium.udid =HGFJGKHLJ
appium.hub = http://127.0.0.1:4666/wd/hub
#appium.systemPort = 8205
appium.appPackage = CP.Android
appium.automationName = uiautomator2
appium.appActivity = crc6429e3927486beccbc.ActivityLicenseBrowse
appium.dontStopAppOnReset = true
appium.resetKeyboard = true
appium.unicodeKeyboard = false
appium.browserName =
#The above capability is needed to run the test...
appium.newCommandTimeout = 5000
appium.noReset=true
appium.skipDeviceInitialization = true
appium.skipServerInstallation = true
#Skips unlock during session creation
appium.skipUnlock = false
appium.noSign = true
#appium.dontStopAppOnReset = true
appium.ignoreUnimportantViews = true
appium.disableAndroidWatchers = true
appium.disableWindowAnimation = true
serenity.project.name = CP Automation Report <br/> <h5> Device: Samsung Galaxy Tab S6 <br/> <h5/>
#serenity.take.screenshots = DISABLED
serenity.take.screenshots = AFTER_EACH_STEP
serenity.console.headings = normal
#serenity.requirement.types = feature, story
step.creation.strategy = legacy
serenity.verbose.steps = true
serenity.logging = verbose
serenity.console.banner=none
serenity.console.headings=none
serenity.reports.show.step.details = false
@RunWith(SerenityRunner.class)
@WithTags({ @WithTag(type = "TP", name = "TP") })
public class TP397_P1_S06 {
@Managed
WebDriver appiumDriver;
@Steps
UserLoginsWithValidCredentials user;
@Steps
TP_Steps tpSteps;
@Steps
UserCreatesPainAreaMap patientLocator;
@Steps
UserCreatesORSession session;
@Steps
UserCreatesORSession createOR;
@Steps
ConfigElectrodePage setAnodeCathode;
@Steps
ORSession_CheckRangeValuesOfTonicStimulationMode verifier, rangeVal;
@Steps
UserVerifiesElectrodeOnORSession electrodeConfig;
@Steps
ProgramConfiguration programConfiguration;
@Steps
ORSession_CheckRangeValuesOfTonicStimulationMode stepSizeSelect;
@Steps
ORSession_RangeValuesPage ampSize, ampUpDown, upDownArrowDisabledForRange, verifyStepSize;
@Steps
NewPatientProfilePage impedances;
@Steps
NewPatientProfilePage screenSelector, impedance;
@Steps
ToastMessageStep toastMessageStep;
String amp, pw, rate, cathode, anode;
int initialImpedanceListCount, finalImpedanceListCount, result;
private static final Logger log = LogManager.getLogger(com.tp.tp397.Procedure1_ORSession.TP397_P1_S06.class);
private static ExecutionListener execListener;
private static ResultWriterCSV resultWriter;
private static boolean dunit = false;
@Title("User logins to the CP Application, searches the patient and creates OR session")
@BeforeAll
public static void setUpTest() {
log.info("************************Start Setup************************");
resultWriter = ResultWriterCSV.getInstance();
// Create listeners to
execListener = new ExecutionListener();
StepEventBus.getEventBus().registerListener(execListener);
user.userOpensTheApplication();
log.info("User launching the application.");
user.userOpensTheApplication();
log.info("user will Login with New credentials successfully.");
user.userEntersNewCredentials();
log.info("User will click on Login.");
user.userClickOnLogin();
patientLocator.userShouldBeAbleToSearchPatientName("Thomas");
patientLocator.userViewsPatientRecord();
// session.createORSession();
session.userShouldBeAbleToViewTheChooseSessionTypePopupAfterClickingOnPlusButton();
session.userViewsCreateNewSessionPageAfterClickingOnORSessionButton();
log.info("user will set A1 as Anode and A2 as Cathode");
setAnodeCathode.setAnode("A1");
setAnodeCathode.setCathode("A2");
log.info("************************Setup Complete************************");
}
@Title("Increase and decrease Amplitudes according to the step sizes")
@Test
public void TP397_ID27_ID32_Test() {
ResultWriterParams.testCaseId = "TP397_ID27_ID32";
ResultWriterParams.acceptanceCriteria = "Increase and decrease Amplitudes according to the step sizes";
rangeVal.userShouldBeAbleToEnterTheRequiredParameterValues("Amplitude", "120");
// Purposely added to fail below test with assertion error
// ampSize.clickOnStep120();
// verifyStepSize.verifyIfStepSizeIsSelected_120("120");
log.info("Amplitude value increases according to their default step size");
verifier.byDefaultUserShouldBeAbleToIncreaseAmplitudeValueAccordingToThierDefaultStepSize(
SessionTestDataConstants.STEP_SIZE_40);
// Test2 - Click the down button
// Verify if application decreases amplitude value by 40µA
System.out.println("Hola-----------------------");
log.info("Amplitude value decreases according to their default step size");
verifier.byDefaultUserShouldBeAbleToDecreaseAmplitudeValueAccordingToThierDefaultStepSize(
SessionTestDataConstants.STEP_SIZE_40);
}
@Title("Amplitude increase is limited to maximum 10200µA and Amplitude decrease is limited to minimum 40µA")
@Test
public void TP397_ID11_ID10_Test() {
ResultWriterParams.testCaseId = "TP397_ID11_ID10";
ResultWriterParams.acceptanceCriteria = "Amplitude increase is limited to maximum 10200µA and Amplitude decrease is limited to minimum 40µA";
rangeVal.userShouldBeAbleToEnterTheRequiredParameterValues("Amplitude", "30");
toastMessageStep.assertIfEqual("Warning! Value out of range. Valid Range: 40 - 10200");
}
@AfterClass
public static void cleanup() {
System.out.println("After class cleanup executed*****************");
resultWriter.close();
}
}