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
5
votes
2 answers

Catch test framework issue: cannot use Catch::Session()

I get this error in a C++ file where I am writing some tests: error: no member named 'Session' in namespace 'Catch' testResult = Catch::Session().run(test_argc, test_argv); ~~~~~~~^ Looking at the catch.hpp single…
Pietro
  • 12,086
  • 26
  • 100
  • 193
5
votes
2 answers

Catch.hpp unit testing: How to dynamically create test cases?

I am using CATCH v1.1 build 14 to do unit testing of my C++ code. As part of the testing, I would like to check the outputs of several modules in my code. There is not a set number of modules; more modules may be added at any time. However, the…
Carrie D.
  • 188
  • 2
  • 12
4
votes
1 answer

Catch2 - undefined reference to

I'm testing my project using Catch2 as library. I followed every step in the Catch doc, but when I run the tests I get the following error: CMakeFiles/tests.dir/tests/IntegerIntervalTest.cpp.o: in function…
sentientmachine
  • 347
  • 3
  • 14
4
votes
3 answers

CATCH unit testing for C++ compare std::array

I like to use catch for my c++ unit tests. My goal is to compare std::array and std::vector. I created the this failing example. #define CATCH_CONFIG_MAIN #include "catch.hpp" TEST_CASE("Vector") { std::vector direction = {0.1, 0.3,…
schorsch312
  • 5,553
  • 5
  • 28
  • 57
4
votes
4 answers

Unresolved external symbol with Catch library

I'm migrating some projects to use CMake build system. Now I'm adding project with some unit tests using the Catch library. It is header only library. The old Visual Studio project builds fine, but the new CMake project gives unresolved external…
bobeff
  • 3,543
  • 3
  • 34
  • 62
4
votes
1 answer

C++ Catch framework 'multiple definition' linker errors with Makefile

Submitting my own answer for Google traffic. Consider the Makefile SHELL := /bin/bash run-tests: catch.o for x in…
Sage Gerard
  • 1,311
  • 8
  • 29
4
votes
2 answers

Does the catch unit test framework support junit-style test reports?

Planning to switch over to the Catch unit test framework for c++. I need the test results to be in junit report format and I just want to confirm if it has that capability.
hopia
  • 4,880
  • 7
  • 32
  • 54
4
votes
1 answer

Catch unit tests in QT creator - multiple definitons of main

I would like to use Catch unit test framework for testing my projects. I read tutorial how to write tests, it was pretty simple. I tried to create really simple project in QT creator, which does include these files:…
Moroxus
  • 41
  • 3
3
votes
1 answer

Combining AND and OR in Catch2 test tags

I have a set of Catch2 test cases, segregated by language and by type. For example: TEST_CASE("zh-CN CPU test", "[zh-CN][cpu]") { REQUIRE(result); } TEST_CASE("zh-CN verification test", "[zh-CN][ModelVerification]") { …
Eric Brown
  • 13,774
  • 7
  • 30
  • 71
3
votes
3 answers

Catch2 - output to console and file

I can run a Catch executable with -o junit --output catch_results.xml to generate an xml report. Is there some way to both generate an xml report, and also have the console output?
Daniel Paczuski Bak
  • 3,720
  • 8
  • 32
  • 78
3
votes
2 answers

Catch testing framework long link time every time

I'm currently attempting to use the Catch testing framework. I'm using cmake to build my project and currently I just glob all the .h and .c files together. For testing purposes I took out my actual "main" and replaced it with the Catch's sample…
efel
  • 1,054
  • 3
  • 14
  • 29
3
votes
1 answer

boost crc yields different output each time

Background I am trying to calculate CRC-16/CRC2 for a given byte array using boost crc lib. Note: I am a beginner at best in C++ development #include #include #include namespace APP{ class CrcUtil{ …
raidensan
  • 1,099
  • 13
  • 31
3
votes
4 answers

How to set up Catch2 in Bazel project

I have started a simple C++ project that uses Bazel as build system and would like to add Catch2 to it, as test framework. This is what my project looks like so far: WORKSPACE -> empty file src/ Money.hpp Money.cpp BUILD where BUILD is…
Martinsos
  • 1,663
  • 15
  • 31
3
votes
1 answer

CMake: How to reuse the same test_main.cpp for each test

I would like to use the test framework Catch2 in a monorepo in which there will be many components, each with their own tests. I'd like to use CMake to define all build targets. Catch2 provides a simple means to generate a common main() function…
4dan
  • 1,033
  • 10
  • 14
3
votes
0 answers

Linker error with Catch and Clang/LLVM on Windows

I have a linker problem with the code below. It works with the Visual Studio 2015 compiler, but not with Clang/LLVM in Visual Studio. I have tried may different variations (some below), all work fine. It seems to be the specific combination of the…
florestan
  • 4,405
  • 2
  • 14
  • 28