Questions tagged [catch-unit-test]

Catch is a unit testing framework for C++

Catch2 is a unit testing framework for C++11 and later. Catch2 offers a BDD syntax, fixtures, Matchers and dynamic data-generation, and a simplified syntax using overloaded assertions. Catch2 is designed for simplicity – it is released as a single include file and allows the use of natural C++ expressions inside assertions.

Catch2 is hosted on GitHub, available at catch-lib.net, and is openly discussed in a Google group.

93 questions
0
votes
2 answers

Getting sections that will be run in Catch

The Catch2 unit test framework allows you to have test sections. From the docs: TEST_CASE( "vectors can be sized and resized", "[vector]" ) { std::vector v( 5 ); REQUIRE( v.size() == 5 ); REQUIRE( v.capacity() >= 5 ); …
Barry
  • 286,269
  • 29
  • 621
  • 977
0
votes
1 answer

Is there a cross-compiler method to disable coverage flags for test executables using CMake?

I am creating a generic C++, CMake, and Catch project template that I plan on using in the future, and want to enable code coverage reports for it. To do so, I decided to add the following CMake module into my list of Modules: CodeCoverage.cmake. My…
Arnav Borborah
  • 11,357
  • 8
  • 43
  • 88
0
votes
2 answers

Using Catch2 in Visual C++ 2015

I'm trying to make a Unit Testing project using the Catch framework, but am faced with Link errors. I've set up the project as follows: Create a Native Unit Test project Add Catch to the include directories Add #include to…
Arya Pourtabatabaie
  • 705
  • 2
  • 7
  • 22
0
votes
1 answer

No testcase tag in Catch JUnit output

When I run my catch unit tests with -r junit, successful test cases are omitted from the output. This causes my Jenkins build to fail because the JUnit plugin is expecting testcase tags in the JUnit XML. Is there anyway to have testcase tags appear…
Maspe36
  • 356
  • 5
  • 12
0
votes
0 answers

How to implement unit tests in "API" program

I'm implementing unit tests (with Catch) in C++ program that performs "API" functions. It consists of a big class with public methods which user could use to interact with an external device. Moreover, there are special private "system" methods…
Stanislav
  • 73
  • 8
0
votes
3 answers

How to exclude printf messages from Catch reporter

I am testing a library that monitors USB stick and allows listening to plugin/plugout events. The target system runs a custom Linux version and debugging is a pain on this system So, for quick analysis of what is going, I very often use printf…
0
votes
2 answers

Errors when compiling catch with Visual Studio 2008

Update: using catch 1.9.7 solved this problem. I am just getting started with using catch and have been unable to get even a simple test project to compile. I am using Visual Studio 2008 and have catch.hpp v1.10.0 (single file version). I created a…
JMayer
  • 101
  • 2
0
votes
0 answers

Catch: what symbol can I use to personalize code for unit-testing

I am using the Catch C++ test framework. I have a separate test-code file, where I have #define CATCH_CONFIG_MAIN #include "catch.hpp" #include "my_own_headers.h" TEST_CASE( "test of thisnthat", "[thisnthat]" ) { SomeStuff a(42); ... Is there…
kebs
  • 6,387
  • 4
  • 41
  • 70
0
votes
0 answers

c++ unit testing with CATCH ambiguous symbol std::size_t

I have this simple code, and I don't understand why it gives me the red squiggly line under TEST_CASE("") saying it is an AMBIGUOUS SYMBOL std::size_t. It compiles fine but that red line is anoying and I don't understand it. #include…
Jason Grant
  • 77
  • 1
  • 5
0
votes
1 answer

Running Catch test cases over a dynamic set of files

I am looking for a way to run a test case in the Catch framework (https://github.com/philsquared/Catch) over a set of files. I know I could do something like this: TEST_CASE( "Test", "[Test]" ) { for each file { REQUIRE( ... ); } } But…
MuhKuh
  • 1,049
  • 10
  • 18
0
votes
0 answers

CmakeList - Not able to create correct CMakelist for C++ Project subfolders

I have a C++ Project folder which contains two folders. a C++ src folder with multiple sub-folders and CmakeList.txt file. The src folder contains main.cpp file. **Cmakelist.txt src folder** project (TestProject) # Include all global directories…
user4477835
0
votes
1 answer

Integrating C++ Catch unit test framework with CMake

I am developing my application using Visual Studio 2015. I have 6 projects in the solution of which 5 are libraries and one is a executable. The executable project contains my test files and I am using Catch framework for testing. So I will be…
Jackzz
  • 1,417
  • 4
  • 24
  • 53
0
votes
2 answers

Test C++ template class using Catch framework

I'm looking for a good way to use Catch to test a templated class. I have something that almost works: #define RUN_ALL(fn, params) \ fn(params); \ fn(params); \ fn(params); \ fn
Zack
  • 6,232
  • 8
  • 38
  • 68
0
votes
0 answers

Catch test framework consumes all memory

My test/ folder has these files test/SimulationTest.cpp test/main.cpp test/HouseTest.cpp the main.cpp file has only this, as per Catch instructions. #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp…
0
votes
1 answer

Containing the combinatorial explosion of test cases using Catch

Let us say I have a simple class which takes 6 boolean arguments in its constructor and performs some computation based on the state of those arguments. If I want to use Catch to adequately test all of the cases, then I would need 64 separate unit…
rohitsan
  • 1,001
  • 8
  • 31