Skip to content
forked from Azure/ctest

A simple portable C test runner

License

Notifications You must be signed in to change notification settings

mdavis777/ctest

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

ctest

ctest is a simple portable C test runner.

Setup

  1. Clone ctest by:
git clone https://github.com/Azure/ctest
  1. Create a folder called cmake (or any name of your choice).

  2. Switch to the cmake folder and run

cmake ..

Build

Switch to the cmake folder and run:

cmake --build .

Installation and Use

Optionally, you may choose to install ctest on your machine:

  1. Switch to the cmake folder and run

    cmake --build . --target install
    

    or

    Linux:

    sudo make install
    

    Windows:

    msbuild /m INSTALL.vcxproj
    
  2. Use it in your project (if installed)

    find_package(ctest REQUIRED CONFIG)
    target_link_library(yourlib ctest)
    

Building the tests

In order to build the tests use the run_unittests cmake option:

cmake .. -Drun_unittests:bool=ON

Example

#include "ctest.h"
#include "SomeUnitUnderTest.h"

CTEST_BEGIN_TEST_SUITE(SimpleTestSuiteOneTest)

CTEST_FUNCTION(Test1)
{
    // arrange

    // act
    int x = SomeFunction();

    // assert
    CTEST_ASSERT_ARE_EQUAL(int, 42, x);
}

CTEST_END_TEST_SUITE(SimpleTestSuiteOneTest)

About

A simple portable C test runner

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C 89.7%
  • CMake 6.5%
  • C++ 2.1%
  • Shell 1.7%