如何从黄瓜的挂钩中跳过测试用例的执行

时间:2018-06-25 06:55:37

标签: selenium cucumber cucumber-jvm

仅当viewPort很大时,我才必须跳过测试案例@bannerVerificationSMMDView的执行

@Before
    public void beforestartUp(Scenario scenario) throws IOException {    
     boolean runTest = true;
        if (viewPort.contains("LARGE")) {
            System.out.println("for Scenario " + scenario.getName() + " tagname are");
            List<String> tags = (List<String>) scenario.getSourceTagNames();
            for (String tagName : tags) {
                if (tagName.contains("bannerVerificationLView"))
                    runTest = false;
            }
            try {
                Assume.assumeTrue(runTest);
            } catch (AssumptionViolatedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
   }

不知道为什么,但是没有捕获到异常

1 个答案:

答案 0 :(得分:3)

抛出No changes. Infrastructure is up-to-date. This means that Terraform did not detect any differences between your configuration and real physical resources that exist. As a result, no actions need to be performed. 以跳过场景的执行。

AssumptionViolatedException

如果您使用的是黄瓜3及更高版本,则可以改用@Before(value="@bannerVerificationSMMDView") public void before(Scenario scenario) { if(viewPort.contains("LARGE")) throw new AssumptionViolatedException("Skipping as view is LARGE"); } 批注,其他所有内容均应相同。这将允许您运行方案中的所有先前步骤,如果不满足条件,则跳过方案中的其余步骤