Is it possible to skip a scenario with Cucumber-JVM at run-time

后端 未结 7 584
面向向阳花
面向向阳花 2020-12-30 12:54

I want to add a tag @skiponchrome to a scenario, this should skip the scenario when running a Selenium test with the Chrome browser. The reason to-do this is because some sc

7条回答
  •  难免孤独
    2020-12-30 13:37

    I realized that this is a late update to an already answered question, but I want to add one more option directly supported by cucumber-jvm:

    @Before //(cucumber one)
    public void setup(){
        Assume.assumeTrue(weAreInPreProductionEnvironment);
    }
    

    "and the scenario will be marked as ignored (but the test will pass) if weAreInPreProductionEnvironment is false."

    You will need to add

    import org.junit.Assume;
    

    The major difference with the accepted answer is that JUnit assume failures behave just like pending

    Important Because of a bug fix you will need cucumber-jvm release 1.2.5 which as of this writing is the latest. For example, the above will generate a failure instead of a pending in cucumber-java8-1.2.3.jar

提交回复
热议问题