SQLite 的测试代码与生产代码的比例

2022-01-14 00:00:00 testing automated-tests c sqlite

SQLite 声称测试代码是生产代码的 679 倍.http://www.sqlite.org/testing.html

SQLite claim to have 679 times more test code than production one. http://www.sqlite.org/testing.html

有谁知道这怎么可能?他们会自动生成任何测试代码吗?这些45678.3 KSLOC"测试代码的主要部分是什么?

Does anyone knows how it is possible? Do they generate any test code automatically? What are the major parts of these "45678.3 KSLOC" of test code?

推荐答案

有人知道怎么可能吗?"

"Does anyone knows how it is possible?"

有可能"拥有 679 倍的测试代码,因为一个功能可以以多种不同的方式使用.只考虑一个带有两个参数的函数.我可以为一个测试边界条件和许多其他条件组合的函数生成大量测试代码.当您考虑测试的设置/拆卸时,那里有额外的代码.根据他们的测试框架,这种开销可能会显着增加测试中的代码量.

"It is possible" to have 679 times as much test code because a single feature can be used in many different ways. Consider just a single function that takes two parameters. I can generate alot of test code for that one function that tests boundary conditions and many other combinations of conditions. When you consider setup/teardown of the tests, there is additional code there. Depending on their testing framework this overhead may significantly add to the amount of code in testing.

真正归结为一个软件可以以多种不同方式使用这一事实,这意味着您有许多不同的场景要测试.这就是优雅的软件,因为一个简单的程序可以应用于多种场景,但这也是使验证和测试软件如此具有挑战性的原因.

What it really boils down to is the fact the a piece of software can be used in so many different ways, which means that you have many different scenarios to test for. This is the beauty of elegant software, in that a simple program can be applied to numerous scenarios, but that is the same thing that makes verifying and testing software so challenging.

相关文章