GitHub - jwgrenning/cpputest-starter-project-vs: A cpputest starter project with instructions for visual studio (original) (raw)

cpputest-starter-project-vs

A cpputest starter project with instructions for Visual Studio

Create Your First Legacy C/C++ Test Project - Visual Studio

This describes how to integrate CppUTest based testing into your production code base using the Visual Studio environment. I'll assume you are using Visual Studio 2010 in the instructions, but there are other project files. As a reference, here are the other Visual Studio file extensions:

• VC6 file extensions (dsw, dsp)
• VS2008 file extensions (sln, vcproj)
• VS2010 file extensions (sln, vcxproj)
• VS2012 file extensions (sln, vcxproj)
• VS2019 file extensions (sln, vcxproj)

Install and build CppUTest

...................................  
OK (1085 tests, 1037 ran, 2505 checks, 48 ignored, 0 filtered out, 331 ms)  

Unzip and build the starter project

Clone the starter-kit like this:

git clone https://github.com/jwgrenning/cpputest-starter-project-vs.git
..  
OK (2 tests, 2 ran, 1 checks, 0 ignored, 0 filtered out, 0 ms)  

How to integrate testing into your source repository.

ProductRepository  
    |-- include  
    |-- source  
    • example-include/example.h  
    • example-include/io.h  
    • example-platform/io.c  
    • example-src/example.c  
    • tests/*.cpp  
    • vs-test-build/AllTests.vcxproj (VS2010)  
    • vs-test-build/ProductionCodeLib.vcxproj (VS2010)  
    • vs-test-build/TddC-StarterProject.dsw  
    • vs-test-build/TddC-StarterProject_VS2010.sln (VS2010)  
    ProductSourceRepository
        |-- example-include
        |-- example.h
        |-- io.h
        |-- example-platform
        |-- io.c
        |-- example-src
            |-- example.c
        |-- include
        |-- source
        |-- tests
            |-- AllTests.cpp
        |-- ExampleTest.cpp
            |-- MyFirstTest.cpp
    |-- vs-test-build
            |-- AllTests.vcxproj
        |-- ProductionCodeLib.vcxproj
            |-- TddC-StarterProject.dsw
            |-- TddC-StarterProject_VS2010.sln
..  
OK (2 tests, 2 ran, 1 checks, 0 ignored, 0 filtered out, 2 ms)  
.  
tests\ExampleTest.cpp(21): error: Failure in TEST(Example, test1)  
        expected <1 0x1>  
        but was  <0 0x0>  
.  
Errors (1 failures, 2 tests, 2 ran, 1 checks, 0 ignored, 0 filtered out, 14 ms)  

Things that can go wrong: