You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently though a step in @before fails my @test still runs. Is there a way to skip @test if @before fails? Also I don't see anything in the serenity listeners that will handle @before failures. What do I do in such case?
`@Override
public void beforeEachTest()
{
/*
* This section assumes Patient James exists in CP.
*/
log.info("beforeEachTest called!");
resultWriter.setTestProtocolID(TP_ID);
//Login to CP, search and select patient James.
cpApp.Login.Login("147258");
cpApp.MyPatients.Search("James");
cpApp.MyPatients.EnterFirstPatient();
//Navigate to Devices tab and associate ETM device. Register IPG as Patient's device.
cpApp.Patient.TapDevices();
cpApp.Patient.Devices.SelectPermanent();
cpApp.Patient.Devices.AssociateBlueETX(Equipment.ETM1);
cpApp.LoaderScreen.waitUntilLoaderDisappears(20);
cpApp.Patient.Devices.RegisterIPGasPatientDevice();
//Navigate to Sessions tab and attempt to add a session.
cpApp.Patient.TapSessions();
cpApp.Patient.Sessions.AddSession();
}
@Title("TP397-002")
@Test
public void Test001()
{
TP397_002.has(
new AcceptanceCriteria("Toast message appeared.")
.with(new ExpectedResult<Boolean>(true)),
new AcceptanceCriteria("Toast message Session cannot be created.")
.with(new ExpectedResult<String>("Error: Patient doesn't have.")),
new AcceptanceCriteria("OR Session is not created (screen remains on Sessions screen).")
.with(new ExpectedResult<Boolean>(true))
);
//Select OR Session option.
cpApp.Patient.Sessions.ChooseORSession();
cpApp.ToastMessage.waitFor();
}`
Listener class
`
public class ExecutionListener implements StepListener
{
ResultWriterCSV resultWriter = ResultWriterCSV.getInstance();
String stepTitle="";
Boolean reportStep = false;
@Override
public void testSuiteStarted(Class<?> storyClass) {
// TODO Auto-generated method stub
}
@Override
public void testSuiteStarted(Story story) {
// TODO Auto-generated method stub
}
@Override
public void testSuiteFinished() {
System.out.println("Test Suite finished*****************");
}
@Override
public void testStarted(String description) {
// TODO Auto-generated method stub
}
@Override
public void testStarted(String description, String id) {
// TODO Auto-generated method stub
}
@Override
public void testFinished(TestOutcome result) {
//AK: Can we know from TestOutcome whether the @Before method succeeded?
String failureObservation = result.getTestFailureMessage();
if(result.isFailure()){
resultWriter.appendTestCaseResultToCSV(TP397_Constants.testCaseResult_FAIL);
}else if(result.isError()){
resultWriter.appendTestCaseResultToCSV(failureObservation, TP397_Constants.acceptanceCriteriaResult_NOT_TESTED);
}else if(result.isSkipped()) {
//Do nothing if test is skipped
}else{
resultWriter.appendTestCaseResultToCSV(TP397_Constants.testCaseResult_PASS);
}
}
@Override
public void testRetried() {
// TODO Auto-generated method stub
}
@Override
public void stepStarted(ExecutedStepDescription description) {
// TODO Auto-generated method stub
}
@Override
public void skippedStepStarted(ExecutedStepDescription description) {
// TODO Auto-generated method stub
}
@Override
public void stepFailed(StepFailure failure) {
// TODO Auto-generated method stub
}
@Override
public void lastStepFailed(StepFailure failure) {
// TODO Auto-generated method stub
}
@Override
public void stepIgnored() {
// TODO Auto-generated method stub
}
@Override
public void stepPending() {
// TODO Auto-generated method stub
}
@Override
public void stepPending(String message) {
// TODO Auto-generated method stub
}
@Override
public void stepFinished() {
// TODO Auto-generated method stub
}
@Override
public void testFailed(TestOutcome testOutcome, Throwable cause) {
// TODO Auto-generated method stub
}
@Override
public void testIgnored() {
// TODO Auto-generated method stub
}
@Override
public void testSkipped() {
// TODO Auto-generated method stub
}
@Override
public void testPending() {
// TODO Auto-generated method stub
}
@Override
public void testIsManual() {
// TODO Auto-generated method stub
}
@Override
public void notifyScreenChange() {
// TODO Auto-generated method stub
}
@Override
public void useExamplesFrom(DataTable table) {
// TODO Auto-generated method stub
}
@Override
public void addNewExamplesFrom(DataTable table) {
// TODO Auto-generated method stub
}
@Override
public void exampleStarted(Map<String, String> data) {
// TODO Auto-generated method stub
}
@Override
public void exampleFinished() {
// TODO Auto-generated method stub
}
@Override
public void assumptionViolated(String message) {
// TODO Auto-generated method stub
}
@Override
public void testRunFinished() {
System.out.println("Test run finished*****");
resultWriter.close();
}
}
`
The text was updated successfully, but these errors were encountered:
The listeners do not affect test outcomes, they are intended for read-only operations. If it is an excepted failure, you could catch the exception in the @before clause and throw a Compromised exception, to distinguish from failing tests and tests that are skipped for some other reason.
Currently though a step in @before fails my @test still runs. Is there a way to skip @test if @before fails? Also I don't see anything in the serenity listeners that will handle @before failures. What do I do in such case?
`@Override
public void beforeEachTest()
{
/*
* This section assumes Patient James exists in CP.
*/
log.info("beforeEachTest called!");
resultWriter.setTestProtocolID(TP_ID);
}`
Listener class
`
public class ExecutionListener implements StepListener
{
}
`
The text was updated successfully, but these errors were encountered: