什么是使用Boost你最喜欢/推荐的项目结构和文件结构进行单元测试? [英] What is your favorite/recommended project structure and file structure for Unit Testing using Boost?

查看:86
本文介绍了什么是使用Boost你最喜欢/推荐的项目结构和文件结构进行单元测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有使用单元测试,到目前为止,我打算采用此过程。我是IM $ P $由T​​DD pssed肯定想给它一个尝试 - 我几乎可以肯定这是要走的路。

I have not used Unit Testing so far, and I intend to adopt this procedure. I was impressed by TDD and certainly want to give it a try - I'm almost sure it's the way to go.

升压看起来像一个不错的选择,主要是因为它的维持。随着中说,我应该如何去实施工作和优雅的文件结构和项目结构?我在Win XP中使用VS 2005。我一直在谷歌上搜索这件事,较开明的更糊涂了。

Boost looks like a good choice, mainly because it's being maintained. With that said, how should I go about implementing a working and elegant file-structure and project-structure ? I am using VS 2005 in Win XP. I have been googling about this and was more confused than enlightened.

推荐答案

我们的加速测试的基础结构是这样的:

Our Boost based Testing structure looks like this:

ProjectRoot/
  Library1/
    lib1.vcproj
    lib1.cpp
    classX.cpp
    ...
  Library2/
    lib2.vcproj
    lib2.cpp
    toolB.cpp
    classY.cpp
    ...
  MainExecutable/
    main.cpp
    toolA.cpp
    toolB.cpp
    classZ.cpp
    ...
  Tests/
    unittests.sln
    ut_lib1/
      ut_lib1.vcproj (referencing the lib1 project)
      ut_lib1.cpp (with BOOST_AUTO_TEST_CASE) - testing public interface of lib1
      ut_classX.cpp - testing of a class or other entity might be split 
                      into a separate test file for size reasons or if the entity
                      is not part of the public interface of the library
      ...
    ut_lib2/
      ut_lib2.vcproj (referencing the lib2 project)
      ut_lib2.cpp (with BOOST_AUTO_TEST_CASE) - testing public interface of lib2
      ...
    ut_toolA/
      ut_toolA.vcproj (referencing the toolA.cpp file)
      ut_toolA.cpp - testing functions of toolA
    ut_toolB/
      ut_toolB.vcproj (referencing the toolB.cpp file)
      ut_toolB.cpp - testing functions of toolB
    ut_main/
      ut_main.vcproj (referencing all required cpp files from the main project)
      ut_classZ.cpp - testing classZ
      ...

选择这种结构的传统项目,在这里我们不得不根据具体情况逐案决定什么测试增加,如何组测试项目,对现有源$ C ​​$ C模块。

This structure was chosen for a legacy project, where we had to decide on a case-by-case basis on what tests to add and how to group test-projects for existing modules of sourcecode.

注意事项:


  • 单元测试code总是单独从生产code编译。

  • 生产的项目不引用的单元测试code。

  • 单元测试项目包括直接的源文件或仅供参考库,取决于情理之中的事情给出了使用一定code-文件。

  • 运行单元测试在每个UT通过生成后步骤完成_ *。vcproj

  • 我们所有的产品构建也自动运行单元测试。 (在我们构建脚本。)

在我们的现实(C ++)世界里,你必须做出权衡BTW。历史遗留问题,开发方便,编译时间,等等。我认为我们的项目结构是一个很好的权衡。 : - )

In our real (C++) world you have to make tradeoffs btw. legacy issues, developer convenience, compile times, etc. I think our project structure is a good tradeoff. :-)

这篇关于什么是使用Boost你最喜欢/推荐的项目结构和文件结构进行单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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