Port of schuchert.wikispaces.com


cpptraining.cpputest.vs2008

cpptraining.cpputest.vs2008

Overview

These instructions are for Version 2.3 of CppUTest and Visual Studio 2008.

Setup for Visual Studio 2008

.......!!.........................................
..................................................
..............................................!...
..................................................
..........................!.................
OK (244 tests, 240 ran, 711 checks, 4 ignored, 0 filtered out, 0 ms)

Press any key to continue . . .

Creating a new Solution

Getting the Test Environment Configured

To setup some of the C++ properties, your project must have one .cpp file in in. We’ll create that first and then finish setting up the project to be able to run unit tests.

#include <CppUTest/CommandLineTestRunner.h>

int main() {
  const char* args[] = { "", "-v" };
  return CommandLineTestRunner::RunAllTests(2, args);
}

Now several project options are available to be set.

OK (0 tests, 0 ran, 0 checks, 0 ignored, 0 filtered out, 0 ms)

Press any key to continue . . .

Add a Test File

Now we’ll add a single test file to verify that your system is up and running, although at this point if you have a running solution everything should work fine.

Note: We will be using just source files for our test code.

#include <CppUTest/TestHarness.h>
 
TEST_GROUP(FooTest) {
};
 
TEST(FooTest, TestName) {
  LONGS_EQUAL(1, 1);
}
TEST(FooTest, TestName) - 0 ms

OK (1 tests, 1 ran, 1 checks, 0 ignored, 0 filtered out, 0 ms)

Press any key to continue . . .

Congratulations, you’re ready to get going.


Comments

" Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.