In this column, I'll show you the basics of adding assertions to your code, demonstrating a couple of different ways to enable and disable them for optimum code testing and performance.
在本专栏文章中,通过演示两种不同的方式来启用和禁用断言以便优化代码测试和性能,我将向您讲述一些有关向代码中添加断言的基本知识。
Many developers use a variant of testing called test-after development (TAD), whereby you write the code and then write the unit tests.
许多开发人员使用称为后测试开发(TAD)的各种测试,你首先编写代码,然后编写单元测试。
I usually work by making small changes to the code and then testing the new code before I move on.
我的工作通常是在向前进展之前,在核心组件做一个小的变化然后测试新的代码。
Quality: Testing code can be one of the most efficient ways to find defects in your application.
质量:测试代码是找到你的程序中缺陷的最有效率的方法之一。
You can download the code for the testing tools from this article.
您可以从本文下载这些测试工具的代码。
There’s also the issue of testing code paths for each experiment.
每个试验中还存在代码测试路径的问题。
What do you think the most common mistake developers make in respect to testing code?
在测试代码方面,你觉得开发人员可能犯的最常见的错误是什么?
The next step beyond testing code is measuring the tests with a code coverage tool.
对代码进行测试的下一步是用代码覆盖工具对测试进行度量。
Most developers, whether they test their code or not, have at least gotten a lecture about testing code at some point.
大部分开发人员(不管他们是否测试自己的代码)至少都了解过关于代码测试的课程。
While services are good and can make your applications more flexible, they also increase the complexity of your code base and testing strategy.
尽管服务很好,它能够使你的应用更灵活,但它也增加了你代码基础和测试策略的复杂性。
One of the most critical measurements for testing is code coverage.
代码覆盖率就是最重要的测试指标之一。
More support for testing whether code does or doesn't throw an exception.
为测试提供了更多的支持,无论代码是否抛出异常。
You may be testing this code to see the results of this effort firsthand.
您可以测试这段代码以直接查看这次尝试的结果。
You still need to design a sound application and develop it with solid and reusable code and thorough testing.
您仍需要设计一个完善的应用程序,用可重复使用的可靠代码开发它,并对其进行彻底测试。
Developers are responsible for the quality of their code, doing the testing needed.
开发人员进行必要的测试,他们对他们的代码质量负责。
At the same time, recording all test scenarios can create duplicate test code when you're testing similar scenarios.
同时,在测试与以前类似的场景时,记录所有测试场景会创建重复的测试代码。
If a unit test is harder to write than the code it is testing, it might be a functional test.
如果编写单元测试比编写其所测试的代码更难,则它可能是功能测试。
Download the code for the testing tools from this article.
可从本文下载测试工具的代码。
Developers also like WTE because any code that is changed during testing is automatically incorporated into the original code.
开发者也喜欢wte,因为在测试期间更改的任何代码都会自动并入原始代码中。
Unfortunately, code coverage testing only makes sure you're executing all the code you'd like to test.
不幸的是,代码覆盖测试只能确保您想要测试的所有代码得到执行。
Your job is easier if you have the freedom to refactor the code you're testing.
如果能够自由地重构正在测试的代码,您的工作会简单些。
In most cases, simple test functions are more than adequate for testing code.
在大多数情况下,简单的测试函数对测试代码来说已经足够了。
Okay maybe I am oversimplifying - you might need minor code changes and regression testing.
好吧,也许我说得太过轻松了——你可 能需要细微的代码修改和回归测试。
Since the online store was already live, we would never roll out new code without first testing it and gathering detail metrics.
由于在线商店已经上线了,我们只有在对新代码进行测试以及搜集数据之后才能发布。
As the code base grows, manual testing becomes an impossible task, and every code change made, big or small, could affect the entire application.
随着代码库的增长,手动测试已经变成不可能完成的任务,无论是大是小,所有代码的变化都会对整个应用程序产生影响。
Performing integration testing on code supplied from multiple sources is quite different from testing code from a single source.
对多来源的代码进行集成测试与对单来源的代码进行集成测试是很不同的。
Instead of placing building blocks under measured forces to test their structural integrity, software engineers write code for their testing.
与通过施加压力来测试建筑砖块的结构完整性不同的是,软件设计者靠编写代码来测试他们的程序。
These folks have direct responsibility for designing, building, and testing the code.
这些家伙对设计、构建、测试负有直接责任。
It allows developers to hide from defects and from testing code.
开发人员可以避开缺陷和测试代码。
Make their code available for testing quickly and easily.
使它们的代码能够被测试快速且方便的利用。
应用推荐