如何规划白盒测试

发布于 2024-09-02 16:07:06 字数 160 浏览 7 评论 0原文

我对白盒测试领域比较陌生,需要帮助为我目前正在进行的项目之一设计测试计划。目前,我只是四处寻找可测试的代码片段,然后为此编写一些单元测试。不知怎的,我觉得这远不是应该做的事情。请您给我一些建议,告诉我如何为测试这个项目做最好的准备?我可以使用任何工具或测试计划模板吗?如果有区别的话,使用的语言是 C++。

I'm relatively new to the world of WhiteBox Testing and need help designing a test plan for 1 of the projects that i'm currently working on. At the moment i'm just scouting around looking for testable pieces of code and then writing some unit tests for that. I somehow feel that is by far not the way it should be done. Please could you give me advice as to how best prepare myself for testing this project? Any tools or test plan templates that I could use? THe language being used is C++ if it'll make difference.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

岁月流歌 2024-09-09 16:07:07

尝试“有效地处理旧代码”:http://www.amazon.com/Working -Effectively-Legacy-Michael-Feathers/dp/0131177052

这是相关的,因为“遗留”意味着没有测试的代码。也是一本比较不错的书。

相关工具有:http://code.google.com/p/googletest/http://code.google.com/p/gmock/
可能还有其他单元测试和模拟框架,但我对这些很熟悉,并且强烈推荐它们。

Try "Working Effectively with Legacy Code": http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052

It's relevant since by 'legacy' he means code that has no tests. It's also a rather good book.

Relevant tools are: http://code.google.com/p/googletest/ and http://code.google.com/p/gmock/
There may be other unit test and mock frameworks, but I have familiarity with these and I recommend them highly.

简单 2024-09-09 16:07:06

白盒测试的目标之一是覆盖 100%(或尽可能接近)的代码语句。我建议找到一个 C++ 代码覆盖率工具,以便您可以查看测试执行了哪些代码以及错过了哪些代码。然后设计测试,以便测试尽可能多的代码。

另一个建议是查看 if 语句、for 循环、while 循环等中的边界条件,并测试它们是否存在任何“灰色”区域、误报和漏报。

您还可以设计测试来查看重要变量的生命周期。测试它们的定义、用法和破坏,以确保它们被正确使用:)

有三个想法可以帮助您开始。祝你好运

One of the goals of white-box testing is to cover 100% (or as close as possible) of the code statements. I suggest finding a C++ code coverage tool so that you can see what code your tests execute and what code you have missed. Then design tests so that as much code as possible is tested.

Another suggestion is to look at boundary conditions in if statments, for loops, while loops etc. and test these for any 'gray' areas, false positives and false negatives.

You could also design tests to look at the life cycle of important variables. Test their definition, their usage and their destruction to make sure they are being used correctly :)

There's three ideas to get you started. Good luck

罪歌 2024-09-09 16:07:06

目前,我只是四处寻找可测试的代码片段,然后为其编写一些单元测试。不知何故,我觉得这远远不是应该做的方式。

人们说“测试驱动开发”的主要好处之一是它鼓励您在设计组件时考虑到可测试性:它使您的组件更具可测试性。


我个人(非 TDD)的方法如下:

  • 了解所需和实现的功能:“先验”(即通过阅读/了解软件功能规范),并通过阅读源代码对功能进行逆向工程
  • 实现黑色对所有已实现/所需功能进行盒测试(例如,请参阅“应该测试内部实现,还是只测试公共行为?”) 。

因此,我的测试并不完全是“白盒”,只是我对正在测试的功能进行了逆向工程。然后,我测试逆向工程的功能,并避免出现任何无用(因此未经测试)的代码。我可以(但不经常)使用代码覆盖率工具来查看黑盒测试执行了多少源代码。

At the moment i'm just scouting around looking for testable pieces of code and then writing some unit tests for that. I somehow feel that is by far not the way it should be done.

People say that one of the main benefits of 'test driven development' is that it ecourages you to design your components with testability in mind: it makes your components more testable.


My personal (non-TDD) approach is as follows:

  • Understand the functionality required and implemented: both 'a priori' (i.e. by reading/knowing the software functional specification), and by reading the source code to reverse-engineer the functionality
  • Implement black box tests for all the implemented/required functionality (see for example 'Should one test internal implementation, or only test public behaviour?').

My testing therefore isn't quite 'white box', except that I reverse-engineer the functionality being tested. I then test that reverse-engineered functionality, and avoid having any useless (and therefore untested) code. I could (but don't often) use a code coverage tool to see how much of the source code is exercised by the black box tests.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文