黄瓜动态使用多个示例表

时间:2015-09-10 22:42:02

标签: ruby cucumber

是否可以根据之前的步骤使用不同的表?

假设我有类似

的东西
<script type="text/javascript">

jQuery(document).ready(function(){
    jQuery('img').each(function(index){
        // check if browser is html5 compatible or not
        var img = jQuery(this);
        if (typeof img.naturalWidth == "undefined") {
            var newImg = new Image();
            newImg.src = img.attr('src');
            if(newImg.height == 80 && newImg.width == 80){
                jQuery(this).attr("src", "/2/files/no_image.jpg")
            }
        }else{
            if(img.naturalWidth == 80 && img.naturalHeight == 80)jQuery(this).attr("src", "/2/files/no_image.jpg");
        }
    });
});

</script>

这是可能的,结构是什么?

1 个答案:

答案 0 :(得分:0)

不,不,这是一个非常糟糕的主意。通常,当您想在场景中进行编程时,应该通过

进行编程
  1. 给它起个名字
  2. 将编程推入步骤定义
  3. 在这种特殊情况下,您似乎希望进行某种详尽的测试,在这种测试中,您可以在多种不同条件下尝试单个操作。黄瓜不适合这种测试。而是找到一种在较低抽象级别进行这类测试的方法,例如单元测试。

    不在Cucumber中进行详尽测试的主要原因是运行时成本。作为一个粗略的经验法则,每个集成测试(Cucumber)的运行时间成本为数百个单元测试(可能是数千个良好的单元测试)。