单元测试间协作

it2022-05-06  4

目录

摘要

内容

Getting Your Team On Board with Unit Testing让您的团队参与单元测试

Unit Test Documentation单元测试文档

Unit Testing as a Collaborative Strategy单元测试作为协作策略

作者


摘要

Unit testing can be one of those polarizing topics in software development. But Joe DeMeyer says good unit testing allows you to explore products deeper, lowers your estimate, improves quality, and maintains productivity pace. Here, he talks about how you can get your developers and business team on board.

单元测试可能是软件开发中的两个极化主题之一。 但Joe DeMeyer表示,良好的单元测试可以让您更深入地探索产品,降低估算,提高质量并保持生产力。 在这里,他谈到了如何让您的开发人员和业务团队参与进来。

内容

Allow me to give a suggestion: Make unit testing a part of every test strategy. Add it in with exploratory and tool-based techniques, but make sure you add it. Good unit testing allows you to explore products deeper, lowers your estimate, improves quality, and maintains productivity pace.

请允许我提出一个建议:让单元测试成为每个测试策略的一部分。 使用探索性和基于工具的技术添加它,但请确保添加它。 良好的单元测试使您可以更深入地探索产品,降低估算,提高质量并保持生产力的节奏。

I don’t expect you to design or execute the unit tests, but having unit testing as an explicit part of your test strategy says you depend on it and expect it to help deliver quality products. 

我不指望您设计或执行单元测试,但将单元测试作为测试策略的明确部分表示您依赖它并期望它有助于提供高质量的产品。

When you discuss strategy, explore the multiple benefits of unit testing. It can 当您讨论策略时,请探索单元测试的多重好处。 它可以:

Evaluate basic functionality and requirements, allowing you to explore deeper and more diverse scenarios评估基本功能和需求,使您能够探索更深入,更多样化的场景Reduce your estimate because the time spent evaluating requirements is now better spent in other scenarios. The time spent in requirements-based testing can be part of the development estimate 减少您的估算,因为评估需求所花费的时间现在可以更好地用于其他方案。 基于需求的测试所花费的时间可以作为开发估算的一部分Help you explore areas that are difficult for black-box techniques. The tester collaborates with the developer to probe those areas and reduce defects that are difficult to locate or reproduce 帮助您探索黑盒技术难以实现的领域。 测试人员与开发人员合作探测这些区域并减少难以定位或重现的缺陷Reduce defects to help maintain productivity pace 减少缺陷以帮助维持研发节奏

So, you may be asking: Why doesn’t everybody do it?所以,你可能会问:为什么不是每个人都这样做?

Unit testing can be one of those polarizing topics in software development. Many developers do not plan, create, execute, or record their testing. The ensuing defects erode their credibility, cause delays in projects, or cause focus to shift away from product development.

单元测试可能是软件开发中的两个极化主题之一。 许多开发人员不计划,创建,执行或记录他们的测试。 随之而来的缺陷削弱了他们的可信度,导致项目延迟,或导致重点转向产品开发。

If your project is not seeing adequate unit testing, here are some thoughts on its benefits and ideas you can use to collaborate with developers.

如果您的项目没有看到足够的单元测试,那么可以考虑一下它可以用来与开发人员协作的好处和想法。

Getting Your Team On Board with Unit Testing让您的团队参与单元测试

For the purpose of this article, I discuss unit testing in the context of software development, and I think of unit testing as the same thing as development testing, low-level testing, or component testing. I submit that unit testing is any action a creator makes to check a change they made, and it is not necessarily automated. The unit test of a change can be a review or a demonstration of functionality—or, preferably, both.

为了本文的目的,我在软件开发的背景下讨论单元测试,我认为单元测试与开发测试,低级测试或组件测试是一回事。 我提出单元测试是创建者为检查他们所做的更改而做出的任何操作,并且不一定是自动化的。 变更的单元测试可以是评论或功能演示 - 或者最好是两者。

Under this definition, notice that I don't constrain anyone to just source code. There are many files that are necessary for an application to operate successfully. The application file itself, component files the application may reference, configuration files that direct behavior, database files, schema files, and debug files work together to deliver functionality. Each of these files can be impacted by a change to the source files used to construct the application, so any change to any file is a candidate for a unit test.

根据这个定义,请注意我并不限制任何人接近源代码。 应用程序成功运行需要许多文件。 应用程序文件本身,应用程序可能引用的组件文件,指导行为的配置文件,数据库文件,模式文件和调试文件协同工作以提供功能。 这些文件中的每一个都可能受到用于构造应用程序的源文件的更改的影响,因此对任何文件的任何更改都是单元测试的候选者

Any change? you may be asking. Joe, if I change a single character in a configuration file, you are suggesting that a unit test is necessary?

任何改变? 你可能会问, Joe,如果我更改配置文件中的单个字符,您是否建议进行单元测试?

Under my definition above, yes. But it depends. For me, it depends on who made the change, the scope of the change, and the context of the change.

根据我的定义,是的。 但这要依具体情况而定。 对我而言,这取决于谁做出了修改,修改的范围和变化的背景。

Who made the change?谁做了修改 As you work with developers, you learn who creates good code and whose code may need more review. You can see this in the number of defects discovered and by listening to conversations between developers. Until a developer proves a certain level of competency in producing good code, I might scrutinize his code a little more. As a test lead, I coach testers along this line, too.

当您与开发人员合作时,您将了解谁创建了良好的代码,并且其代码可能需要更多的审核。 您可以通过发现的缺陷数量和开发人员之间的对话来了解这一点。 在开发人员证明在生成优秀代码方面具有一定程度的能力之前,我可能会更多地审查他的代码。 作为测试负责人,我也沿着这条路线指导测试人员。

Similarly, you also assess a developer’s history in making changes and his familiarity with the products he changes to help determine the right amount of scrutiny.

同样,您还要评估开发人员进行更改的历史以及他对所更改产品的熟悉程度,以帮助确定适当的审查量。

What is the scope?修改的范围是什么 If a developer comes to me and says she made a simple change, I want to know what she means by simple. A unit test for a text change from “unit pest” to “unit test” might be a file comparison (i.e., before and after the change), where a change in the location of a database server might require a unit test demonstration.

如果开发人员来找我并说她做了一个简单的改变,我想通过简单的方式知道她的意思。 从“单位害虫”到“单元测试”的文本变换的单元测试可以是文件比较(即,在变化之前和之后),其中数据库服务器的位置的改变可能需要单元测试演示。

What is the context of the change?修改的背景是什么 Finally, I want to know more about the context of a change. Production issues impacting customers require a brief but focused review. However, something discovered during testing or a drive-by demonstration may require one or more unit test scenarios.

最后,我想更多地了解修改的背景。 影响客户的生产问题需要进行简短而有针对性的审核。 但是,在测试或验收演示期间发现的某些内容可能需要一个或多个单元测试场景。

Unit Test Documentation单元测试文档

The amount of documentation depends on the credibility of the developer and development team, the present defect rate, and code complexity. When the code complexity and defect rate are low and the developer produces solid code, I might have the developer demonstrate the unit tests. This can be completed at his desk. As those dimensions change, I might require a list of bullet points or something closer to a test plan. In that case, I target something that requires half an hour or less to create.

文档量取决于开发人员和开发团队的可信度,当前的缺陷率和代码复杂性。 当代码复杂性和缺陷率较低且开发人员生成可靠代码时,我可能会让开发人员演示单元测试。 这可以在他的办公桌上完成。 随着这些维度的变化,我可能需要一个项目符号列表或更接近测试计划的内容。 在这种情况下,我的目标是需要半小时或更短的时间来创建。

When our project’s defect rate nearly doubled over two iterations, I worked with the lead developer to have developers prepare for unit test demonstrations, to create better documentation, and to require unit test documentation before the code became available for test. Our defects decreased over the succeeding iterations. Because a demonstration and documentation were required, it helped the developer focus the unit tests to cover important functionality and improved the quality delivered to our test environment.

当我们项目的缺陷率在两次迭代中几乎翻倍时,我与首席开发人员一起让开发人员准备单元测试演示,创建更好的文档,并在代码可用于测试之前要求单元测试文档。 在随后的迭代中,我们的缺陷减少了。 由于需要演示和文档,因此它帮助开发人员专注于单元测试,以涵盖重要功能并提高我们的测试环境的质量。

Unit Testing as a Collaborative Strategy单元测试作为协作策略

Unit testing serves to scrutinize new and changed products. The products are as good as the tests, so objectivity is encouraged. However, the level of the unit test is the real value. When a developer unit tests her changes, she demonstrates integrity. Her tests help her understand the behavior of the product. When she demonstrates a product through her unit tests, she improves collaboration. Two minds using the medium of the test to review product behavior creates a shared responsibility and shared outcome.

单元测试用于仔细检查新产品和变更产品。 产品和测试一样好,因此鼓励客观性。 但是,单元测试的级别是实际值。 当开发人员单元测试她的变化时,她会表现出诚信。 她的测试帮助她了解产品的行为。 当她通过单元测试演示产品时,她改善了协作。 使用测试媒介审查产品行为的两个人会产生共同的责任和共同的结果。

When she demonstrates a product to her business team member through her unit tests, she improves confidence. Demonstrating the basics helps the business team members trust her work, frees them to ask deeper questions, and makes them feel part of the solution. A clear, concise, and well-prepared demonstration helps business team members understand their product’s capabilities.

当她通过单元测试向她的业务团队成员展示产品时,她提高了信心。 展示基础知识有助于业务团队成员信任她的工作,使他们能够更深入地提出问题,并让他们感受到解决方案的一部分。 清晰,简洁,准备充分的演示可帮助业务团队成员了解其产品的功能。

With an understanding of the basics, they can explore the product through questions or experiments. Being part of that conversation benefits them and your project team because they are helping to create a solution that fulfills their needs. As a tester, a strategy that includes unit testing facilitates that relationship, improves quality, and saves time.

通过对基础知识的理解,他们可以通过问题或实验来探索产品。 参与该对话有益于他们和您的项目团队,因为他们正在帮助创建满足其需求的解决方案。 作为测试人员,包含单元测试的策略可以促进这种关系,提高质量并节省时间

作者

Joe has been in IT twelve years (seven in development and five in testing), and nineteen years in engineering (fifteen in product development and four in product testing). He is often assigned as test lead on enterprise-level projects.

Joe从事IT工作十二年(开发七年,测试五年),工程十九年(产品开发十五年,产品测试四年)。 他经常被指派为企业级项目的测试负责人。


最新回复(0)