在断言时继续测试用例 [英] Continue test case on assert

查看:94
本文介绍了在断言时继续测试用例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我上次使用testcafe时,我已经意识到在这个出色的框架中缺少我的功能.

last time i am using testcafe i have realized about function which missing me in this great framework. This function is something like "continue executing the rest of particular test despite of fact that assertions appears"

更准确地说,我描述了我缺少诸如此类功能之类的原因: 假设您正在测试Web应用程序(例如Web表单),在其中输入合同日期.这样的合同形式包含很多输入框,下拉菜单,复选框等.

To be more precise, I describe the reason i missing something like such function: Let say you are testing web application like web form where you are entering date for contracts. Such contract forms contains a lot of input boxes, dropdown menu, checkboxes etc.

第一个简单的测试将是这样的:

First simple test will be something like this:

  • 在每个输入中的整个表格中输入数据,标记复选框, 从下拉菜单等中选择值.这只是一项测试,对于 简单的展示柜.

  • entering data all over form in every input, mark chekcboxes, selecting value from dropdown menu etc. This is only one test, for simple show case.

然后,您可以在整个环境中运行此测试,并且一切正常.好的.

Then, you run it this test all over environments, and everything is working fine. Good.

在下一个webapp版本中,您必须测试一切是否正常.但是这个测试在第一个断言时就停止了.现在,您不知道还有多少其他断言,因为测试脚本将在此步骤停止工作.

In next webapp release you have to test if everything is working fine. But this test stopped on first assertion. And at this moment you dont know how many other assertions you have, because test script will stop working at this step.

您所能做的就是在此行中添加注释,然后再次启动测试用例.而且,可以说,下一个断言出现在下一行.

All you can do is comment this line and start test case again. And, let say, next assertion appears on the next line.

您可能知道我的意思. 尽管存在错误,是否可以继续测试,然后编写失败的测试并显示有关所有错误/断言的信息?

You probably know what I mean by that. Is it possible to continue the test despite the error, and then write that test failed and display information about all errors/assertions?

根据我所知道的和我的经验,这时我能做的事都放在了:if-else:之类的每个:except:条件上.但这是重写现有测试脚本的艰巨工作.

From what i know and my experience, all i can do at this moment is put on every :except: condition something like :if - else:. But this is enormy work with rewriting existing test scripts.

我确信不仅我会考虑这一点.但是,可悲的是,我无法在网上找到与Testcafe有关的任何信息,您(专家)如何解决此问题.

I am sure not only me think about this. But, sadly, i am unable to found any information on web in connection with Testcafe, how you, guru's, solving this.

您对此有何看法?

感谢和欢呼

推荐答案

如果上一步失败,则TestCafe不允许运行下一步.原因是在大多数情况下,下一步取决于上一步.

TestCafe does not allow running next steps if a previous step fails. The reason of this is that in most scenarios, the next step depends on the previous step.

例如,用户希望单击一个按钮,该按钮在他/她选择单选按钮项之后出现.如果第一步(选择单选按钮项)失败,则该按钮将不会出现,并且用户将无法单击不可见的元素.因此,运行2、3等步骤没有任何意义.您需要首先解决一个问题,然后才能继续使用您的页面.

For example, a user wishes to click a button, which appears after he/she selects a radio button item. If the first step (selects the radio button item) fails, the button will not appear and the user will not be able to click an invisible element. So, running 2, 3, etc. steps does not make sense. You need to fix an issue at the first step to continue working with your page.

如果您的步骤彼此不依赖,则最好为每个独立方案创建一个单独的测试.在这种情况下,您将能够跳过运行失败的测试并在必要时进行修复.要跳过测试,请使用测试.跳过 TestCafe方法.

If your steps do not depend on each other, it is better to create a separate test for each independent scenario. In this case, you will be able to skip running failed tests and fix them when necessary. To skip tests, use the test.skip TestCafe method.    

这篇关于在断言时继续测试用例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆