eos测试规格_希望您的测试更有效? 这样写您的规格。

测试规范对于识别失败的测试至关重要。好的规范应遵循黄金法则,既不太泛也不太具体,保持简短,用现在时态书写,关注输入和输出。避免嵌套的描述块,针对不同类型的测试编写不同级别的规范,以提高可读性和调试效率。
摘要由CSDN通过智能技术生成

eos测试规格

by Edd Yerburgh

埃德·耶堡(Edd Yerburgh)

希望您的测试更有效? 这样写您的规格。 (Want your tests to be more effective? Write your specifications like this.)

Writing test specifications is tricky. If you get it right, your tests are easy to understand and debug. But get it wrong, and your tests will be confuse people more than they’ll help them.

编写测试规范非常棘手。 如果您做对了,您的测试很容易理解和调试。 但是弄错了,您的测试会使人们更加困惑,而不是帮助他们。

In this article, I’ll show you how to write expressive test specifications.

在本文中,我将向您展示如何编写表达性测试规范。

什么是测试规格? (What are test specifications?)

Test specifications (specs) are the string used to identify tests when they’re run by a test runner.

测试规范(specs)是由测试运行程序运行时用于标识测试的字符串。

Below you can see an example of the output from a failed test. You can see where the specification and assertion error is used to describe how a test failed.

在下面,您可以看到测试失败的输出示例。 您可以看到规范和断言错误用于描述测试失败的位置。

为什么测试规格很重要? (Why are test specifications important?)

When a test fails, the way you identify it is with the test specification.

如果测试失败,则可以通过测试规范来识别它。

If the specification is well-written, you’ll know straight away why the test failed by using the test specification and the test assertion.

如果规范写得好,您将通过使用测试规范和测试断言直接了解为什么测试失败。

calls showModal when button is clickedError: Expected spy to have been called but it was not.

We can guess that the test failed because showModal wasn’t called when the button was clicked. This debugability is what you should aim for in tests.

我们可以猜测测试失败,因为单击按钮时未调用showModal。 这种可调试性是您在测试中应该追求的目标。

Lets look at som

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值