简体   繁体   English

如何为Visual C ++ 2005安装CPPUnit?

[英]How to install CPPUnit for Visual C++ 2005?

I want to start to do some unit testing however I am really confused about how to setup CPPUnit. 我想开始进行一些单元测试,但是我对如何设置CPPUnit感到非常困惑。 I have looked at various tutorials and guides online to find out what to do but there are so many variants of what to do. 我在网上查看了各种教程和指南,以找出要做什么,但是要做什么有很多变体。 I've tried a few ways but none seem to work. 我尝试了几种方法,但似乎都没有用。 If anyone could pont me in the right direction of what to do then I woudl be extremeley grateful. 如果有人能朝正确的方向做事,那么我将非常感激。 I am currently using visual studio 2005 and most of my apps are mainly MFC I also create a fair amount of .net apps so ideally I want it to work for both. 我目前正在使用Visual Studio 2005,并且我的大多数应用程序主要是MFC,而且我还创建了大量的.net应用程序,因此理想情况下,我希望它对两者都适用。 I am a massive newbie so when explaining please try and keep technical jargon down to a minimum as I probably won't understand it. 我是个新手,所以在解释时,请尝试将技术术语降到最低,因为我可能不会理解。

Did you follow this tutorial ? 您是否遵循了本教程

If it is still not working for you, can you please be a bit more specific on what is working for you and what is not? 如果仍然无法为您服务,请您能更详细地说明哪些对您有用,哪些不起作用? Maybe post the link to the tutorial you are following and where it bugs? 也许将链接发布到您正在关注的教程上,并且在哪里出错?

There is no installation. 没有安装。 The distribution is the source code which must be compiled with the compiler you are using for your C++ work. 该发行版是源代码,必须使用您用于C ++工作的编译器进行编译。 Setting up CPPUnit (on windows using Visual Studio): 设置CPPUnit(在使用Visual Studio的Windows上):

  1. Download latest release of CPPUnit from here 此处下载最新版本的CPPUnit
  2. Extract the zip contents (using 7zip or winrar) 解压缩zip内容(使用7zip或winrar)
  3. Open the Visual Studio 6 workspace file in the examples directory of the extracted folder. 在提取的文件夹的示例目录中打开Visual Studio 6工作区文件。
  4. Open file MsDevCallerListCtrl.cpp in the folder srcmsvc6testrunner. 打开文件夹srcmsvc6testrunner中的文件MsDevCallerListCtrl.cpp。 Find the following line: 找到以下行:

    import "libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2" version("7.0") lcid("0") raw_interfaces_only named_guids 导入“ libid:80cc9f66-e7d8-4ddd-85b6-d9e6cd0e93e2”版本(“ 7.0”)lcid(“ 0”)raw_interfaces_only named_guids

  5. Now do a batch build for all configurations. 现在对所有配置进行批处理构建。

  6. Check the lib directory in the cppunit directory. 检查cppunit目录中的lib目录。 If the files cppunit.lib, cppunit_dll.lib and cppunit_dll.dll are in there. 如果文件cppunit.lib,cppunit_dll.lib和cppunit_dll.dll在其中。
  7. Go to Tools->Options->Projects and Solutions->VC++Directories 转到工具->选项->项目和解决方案-> VC ++目录
  8. From the dropdown for "Show directories for" choose "Include Files" and add (by clicking in the blank space on the bottom) -> include 从“显示目录”的下拉列表中,选择“包含文件”并添加(单击底部的空白处)->包含
  9. Now change the Library files by adding lib 现在通过添加lib更改库文件
  10. Check that CPPUnit is now running by loading the CPPUnitTestMain project which can be found in the examples folder. 通过加载可以在示例文件夹中找到的CPPUnitTestMain项目,检查CPPUnit现在正在运行。
  11. Build and Run without debugging. 无需调试即可生成和运行。 If the command line appears showing “OK(222)” appears then CPPUnit is now on your machine. 如果出现命令行显示“ OK(222)”,则CPPUnit现在在您的计算机上。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM