用于检索 xUnit 测试模式中的代码指标的工具?
我正在阅读 Gerard Meszaros 的 xUnit 测试模式。
在其中一页上,他提到了一些软件指标:
虽然需要换行来保留 65 个字符构成此代码 看起来比实际更长,它 仍然是不必要的长。它 包含25条可执行语句 包括初始化声明,6 控制语句行、4 行内注释和 2 行声明测试方法——总共 37 行未包装的源代码。
除了计算语句来找到这些指标之外,有人知道他是否使用了特定的工具来计算指标吗?
(如果您对计算类似指标的工具有任何建议,我正在寻找一个适用于 Java、Javascript 和 C++ 的工具)
谢谢!
I'm reading xUnit Test Patterns by Gerard Meszaros.
On one of the pages he refers to some software metrics:
While the need to wrap lines to keep
them at 65 characters makes this code
look even longer than it really is, it
is still unnecessarily long. It
contains 25 executable statements
including initialized declarations, 6
lines of control statements, 4 in-line comments, and 2 lines to declare the test method—giving a total of 37 lines of unwrapped source code.
Short of counting the statements to find these metrics, does anybody have any idea if he used a particular tool to calculate the metrics?
(If you have any suggestions for tools that will count similar metrics, I'm looking for one that works on Java, Javascript and C++)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
抱歉让你失望了,但我确实用手数过(好吧,是用眼睛)。只有 25 行代码!我只是遍历并计算了分号并减去了未实际执行的行(例如未初始化的变量声明)。
重点不在于有多少行代码,而在于您需要编写的代码行数少了多少(一次)并阅读/理解/修改(多次)。
杰拉德
Sorry to disappoint you but I did count by hand (well, by eye). It's only 25 lines of code! I just went through and counted semi-colons and subtracted lines that weren't acutally executed (like uninitialized variable declarations.)
The point is not exactly how many lines of code there are but rather how much fewer lines of code you need to write (once) and read/understand/modify (many times).
Gerard