CPPUnit Installation Manual

xiaoxiao2021-03-06  16

Compile and install CPPUnit

Download a installation package from http://voxel.dl.sourceforge.net/sourceforge/cppunit/cppunit-1.10.2.tar.gz, then decompressed to the specified directory, and the article refers to the unzip directory with C.

Open $ CPPUNIT / SRC / CPPUNITLIBRARIES.DSW file.

Open the build menu in the VC IDE, select 'Batch Build ...'

In the BATCH Build menu, select all compile items.

Then in the / lib directory you will find all compiled files.

Include Files, Libraries Files, Source File is set separately in the Tools / Options menu.

Ready to start a new project, create a New Console Application, select 'A Simple Application' Template. In Project Setting:

Tab 'C ', multi-selection box 'code generation', setting to 'multithreaded DLL' and 'Debug Multithreaded DLL' for DEBUG and RELEASE, respectively.

Tab 'C ', multi-selection box 'C Langage', select All configurations, select '' Enable Run-Time Type Information (RTTI) '.

Tab 'Link', in 'Object / Library Modules', add CPPUNITD.LIB and CPPUnit.LIB for Debug and Release, respectively.

Tab 'POST-Build Step', select All Configurations, add a command '$ (targetPath) in' Post-Build Command (s) '. This CPPUnit will perform an automated test after the project is compiled.

Change the code of the file where the main function is located is as follows:

#include "stdafx.h"

#include

#include

#include

Int main (int Argc, char * argv [])

{

// Get the top level suite from the registry

CPPUnit :: Test * Suite = cppunit :: testfactoryregistry :: getRegistry ();

// add the test to the list of test to run

CPPUnit :: Textui :: Testrunner Runner;

Runner.addtest (Suite);

// Change the default outputter to a compiler error Format Outputter

Runner.setputPutter (New CPPUnit :: CompilerOutputter (& runner.result (),

std :: cerr));

// Run the tests.

Bool Wassucessful = Runner.Run ();

// Return Error Code 1 if the one of test failed.

RETURN WASSUCESSFUL? 0: 1;

}

Press CTRL F5, the following similar statements appear:

Compiable ...

Unittest.cpp

Linking ...

Unit Testing ...

OK (0)

UnityRetest.exe - 0 Error (s), 0 Warning

So far, it is very good.

PS

Where appears

Stlportxxxx.dll

The case can't be found, because

CPPUnit

Used

STLPORT

Please download the latest version:

http://www.stlport.org/archive/stlport-4.6.2.tar.gz

According to

STLPORT

After the installation and configuration manual are set up.

转载请注明原文地址:https://www.9cbs.com/read-41674.html

New Post(0)