1

I need to skip a scenario from running based on a flag which I obtain from the application dynamically in run-time, which tells whether the feature to be tested is enabled. I don't want to throw any exception.

Sample code:

            if (JIRA_Integration.equalsIgnoreCase("yes")) {
                status = zapi.getTestExecutionStatusInJIRA(scenario.getName());
                if(status.equalsIgnoreCase("pass")){
                    isScenarioAlreadyExecuted = true;
                }else {
                    isScenarioAlreadyExecuted = false;
                }
            } else {
                logger.info("Currently JIRA_Integration is disabled, enable it to update test scenario execution status in JIRA");
            }
        }

        if(isScenarioAlreadyExecuted){
            logger.info("Scenario: \"" + scenario.getName() + "\" is already passed in the previous test cycle");
            throw new AssumptionViolatedException("Scenario: \"" + scenario.getName() + "\" is already passed in the previous test cycle");
        }
Deena P
  • 105
  • 1
  • 2
  • 12
  • You might look into this similar question: https://stackoverflow.com/questions/1689242/conditionally-ignoring-tests-in-junit-4 – unigeek Jan 30 '18 at 14:56
  • Same approach I am using in my code above. Problem with above approach is failed test still shows up as Error in the test summary. I want these scenario/test to be skipped completely or proceed with next scenario/test. – Deena P Jan 31 '18 at 07:17
  • If you're taking the same approach, it's anything but clear that this is the case from your code fragment. I bet you have a similar idea, but your execution is completely different. – unigeek Jan 31 '18 at 14:12
  • Consider not throwing the Exception? – Marit Feb 04 '18 at 05:59

0 Answers0