将C / C ++unit testing与maven集成

我们计划将我们的原生c / c ++项目集成到maven构建过程中,因为我们正在移植Android代码。 此外,我们还要为当前使用CUnit的c / c ++项目制定使用标准maven语法(对于javaunit testing)自动运行的unit testing。 这可能与maven集成吗?

我不确定是否有直接的方法来做到这一点,但我会做以下事情:

  1. 创建一个可配置的shell / batch脚本,负责执行unit testing。
  2. 通过exec插件将脚本绑定到测试阶段,将此脚本的执行集成到maven中。

每次启动surefire插件时,此设置都将运行C ++unit testing,例如。 通过运行: mvn test

或者,您可以使用ANT脚本和antrun插件执行相同操作。

这是一个示例(来自Exec插件使用页面的更改版本):

  ...    org.codehaus.mojo exec-maven-plugin 1.2.1   test  exec     run-cpp-tests.sh     ...