与Maven C / C ++单元测试集成 [英] integration of C/C++ unit test with maven

查看:196
本文介绍了与Maven C / C ++单元测试集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们计划对我们的本地C / C ++项目整合成一个Maven构建过程,我们移植code为Android。再者,我们要制订使用标准的Maven语法(如用于Java单元测试)自动运行单元测试也为目前使用的Cunit的C / C ++项目。这是不可能将其与Maven集成?

We are planning to integrate our native c/c++ projects into a maven build process as we are porting the code for Android. Further we want to formulate unit tests that are run automatically using the standard maven syntax (as for java unit tests) also for the c/c++ projects which are currently using CUnit. Is this possible to integrate it with maven ?

推荐答案

我不知道是否有这样做直接的方式,但我会做到以下几点:

I'm not sure if there is a direct way to do this but I'd do the following:


  1. 创建一个可配置的shell /批处理脚本负责执行单元测试。

  2. 本集成脚本执行到的Maven通过绑定脚本通过的 exec插件

  1. Create a configurable shell/batch script that is responsible for executing the unit tests.
  2. Integrate the execution of this script into maven by binding the script to test phase via the exec plugin.

此设置将运行C ++单元测试,每次当万无一失插件开始时,例如。运行: MVN测试

This setup would run your C++ unit tests every time when the surefire plugin is started, eg. by running: mvn test.

另外,你可以做同样的与 ANT 脚本和的 antrun插件

Alternatively you can do the same with an ANT script and the antrun plugin.

下面是一个例子(从Exec插件的使用页面中修改过的版本):

Here is an example (an altered version from the Exec plugin usage page):

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <executions>
          <execution>
            <phase>test</phase>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <executable>run-cpp-tests.sh</executable>
        </configuration>
      </plugin>
    </plugins>
  </build>
   ...
</project>

这篇关于与Maven C / C ++单元测试集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆