C 嵌入式自动单元测试生成

标签 c unit-testing testing embedded automated-tests

是否有任何软件可以在 C 和嵌入式应用程序中生成单元测试?我问的原因是我的老板告诉我他从某人那里听说“你需要一个工具来分析代码并自动创建所有相关测试用例的 80%,剩下的 20% 是你所有的时间和重点”,否则这会花费“太多时间”。

我对这个说法非常怀疑,看不清楚可以自动生成什么样的测试,以及它们是否有任何好处。

但是,我可以看到可以为 API:s 自动生成接口(interface)单元测试。

那么有人可以在这个问题上启发我吗?

最佳答案

我推荐API Sanity Checker工具:

An automatic generator of basic unit tests for a shared C/C++ library. It is able to generate reasonable (in most, but unfortunately not all, cases) input data for parameters and compose simple ("sanity" or "shallow"-quality) test cases for every function in the API through the analysis of declarations in header files.

The quality of generated tests allows to check absence of critical errors in simple use cases. The tool is able to build and execute generated tests and detect crashes (segfaults), aborts, all kinds of emitted signals, non-zero program return code and program hanging.

独特的特点:

  • 自动生成输入参数和测试数据(即使是复杂的数据类型)
  • 现代 specialized types而不是固定装置和模板

请参阅 FreeType2 的示例.

enter image description here

我是这个项目的作者,你可以问我关于它的任何问题。

关于C 嵌入式自动单元测试生成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2810141/

相关文章:

security - 如何通过“测试驱动开发”确保安全编码?

c - C 多线程程序中的错误

c# - 一次性方法的单元测试

php - 如何检查是否一个接一个地设置直到完成

angular - 当 Cypress E2E 中的任何一个测试失败时,Azure 构建就会失败

unit-testing - 如何验证在单独的 go 例程中调用了一个方法

c - 递归二叉树插入

c - 为什么 gets() 不消耗整行输入?

c - 从图像中读取 UPC 条形码

unit-testing - 单元测试——隔离测试