Questions tagged [catch2]

Catch is a unit testing framework for C++

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.

153 questions
0
votes
1 answer

How to use Catch2 to run from a wxWidgets app

After recently getting to know Catch2, I would very much like to use it to test some functionality of a wxWidgets project. All of the simple examples I have seen run basically as a console app. Others I have seen, are used to instantiate and test a…
Stacker
  • 27
  • 3
0
votes
1 answer

Catch2 does not see my implementation files

My project tree is: Name - Catch-tests -- Catch CMAKE -- test.cpp (included as exec in cmake) - include (stores headers) -- foo.h - src (stores implementation) -- foo.cpp - Cmake for entire project -…
m8dotpie
  • 3
  • 2
0
votes
1 answer

MPI: Check whether any processes have been terminated

I'm writing unit tests with Catch2 for some code that uses MPI. A failed test in Catch2 is basically a failed assertion with helpful error messages. Now, in some cases, mpirun doesn't seem to detect when a test fails on just one process. Then a…
RL-S
  • 734
  • 6
  • 21
0
votes
0 answers

C++ Pattern for Test endless loop called from thread

How i can to test with Catch2 an endless loop called from a thread. e.g: static vector v; //vector with results class foo { public: foo(){} void endless_loop() { while(true) { //long…
0
votes
0 answers

Can VS Code Test Explorer Catch2 extension automatically outdate tests when sources change

I'm using VS Code Test Explorer with python extension on a project. It is awesome. If I change any source files, the relevant tests in Test explorer will be highlighted as out of date so I know I have to run them again to check everything is…
BrendanSimon
  • 665
  • 1
  • 9
  • 23
0
votes
1 answer

Problems with Structs and tests with catch2

So I have the following function in point2D.h header file: VectorXY ASSplinePath::Point2D::create_x_y_vectors(const std::vector>& point_vector) Then in the point2D.cpp file I use this function as follows: template
y_1234
  • 61
  • 1
  • 7
0
votes
1 answer

Why am I getting this SIGSEGV signal in my catch2 test?

I am currently learning c++ and as an exercise, I've been trying to implement a linked list data structure. I am writing tests for it in Catch2 and I keep getting a SIGSEGV signal and I can't figure out why. Here is my linked list header…
Chris Morgan
  • 85
  • 1
  • 6
0
votes
1 answer

Why would this cause a Seg. fault, and how can I use GDB to debug it?

The code itself is extremely simple. I'm using Catch2 to unit test, (I really like its interface) and break into gdb, but getting no useful information for a Seg. fault thrown by said simple code. I know exactly what is causing the problem, but I…
AmagicalFishy
  • 1,249
  • 1
  • 12
  • 36
0
votes
1 answer

How to implement a custom matcher to check for object equality in Catch2

I'm new to unit testing in C++ with Catch2. Lastly, I was trying to implement a custom Matcher to test if the fields of a given object match the ones I provide. The object in question would be like: class Book { private: int chapters; int…
chick3n0x07CC
  • 678
  • 2
  • 10
  • 30
0
votes
2 answers

How do I run tests built using VisualStudio, via CMake/CTest/Catch2 from the CLI?

I'm trying to learn several things at once (arguably my first problem...), namely: unit testing with Catch2 and building with CMake. In the course of my investigations, CTest appeared on the radar as a pre-baked way of managing tests within CMake,…
Edd Inglis
  • 1,067
  • 10
  • 22
0
votes
1 answer

Both DocTest and Catch 2 not running unit test

I'm starting a new win32 C++ project using Visual Studio 2019 (v. 16.0.4) and Resharper (v. 2019.1.1) and can't get either the Catch2 or Doctest unit testing framework to run a test. I prefer Doctest and used that first and when that didn't work, I…
pro3carp3
  • 807
  • 2
  • 7
  • 17
0
votes
1 answer

Unit tests. How to run tests in the main()

I am trying to run a test in the main function, but the error "you cannot overload the main () function"is displayed. #define CATCH_CONFIG_RUNNER // -- main() создавать нужно -- #include "catch.hpp" int main(int argc, char* argv[]) { …
ANurbaev
  • 17
  • 3
0
votes
0 answers

I am writing unit tests. How To Fix LNK1120 Error

I want to write the simplest unit test on visual studio 2017. But there is an error - "fatal error LNK1120: unresolved external elements: 23" #define CATCH_CONFIG_MAIN #include "catch.hpp" TEST_CASE("Test", "[test]") { REQUIRE(1 == 1); }
ANurbaev
  • 17
  • 3
0
votes
1 answer

Pass $(location) to Bazel --test_arg

The question Is it possible to pass a general $(location) to bazel test in the --test_args argument which is re-evaluated for each executed test? Context What I am trying to do is use bazel test to bulk execute tests, but produce unique output…
0
votes
1 answer

What's the gtest equivalent of CATCH_CONFIG_MAIN?

#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file I cannot find alternative of gtest after googling
Chen Li
  • 4,824
  • 3
  • 28
  • 55
1 2 3
10
11