如何规划白盒测试
我对白盒测试领域比较陌生,需要帮助为我目前正在进行的项目之一设计测试计划。目前,我只是四处寻找可测试的代码片段,然后为此编写一些单元测试。不知怎的,我觉得这远不是应该做的事情。请您给我一些建议,告诉我如何为测试这个项目做最好的准备?我可以使用任何工具或测试计划模板吗?如果有区别的话,使用的语言是 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
尝试“有效地处理旧代码”: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.
白盒测试的目标之一是覆盖 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
人们说“测试驱动开发”的主要好处之一是它鼓励您在设计组件时考虑到可测试性:它使您的组件更具可测试性。
我个人(非 TDD)的方法如下:
因此,我的测试并不完全是“白盒”,只是我对正在测试的功能进行了逆向工程。然后,我测试逆向工程的功能,并避免出现任何无用(因此未经测试)的代码。我可以(但不经常)使用代码覆盖率工具来查看黑盒测试执行了多少源代码。
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:
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.