Newest 'catch-unit-test' Questions

Q&A for professional and enthusiast programmers

catch.hpp error messages with visual studio

Using visual studio 2015 to compile a test code using catch.hpp unit test. I need to write code to interface with serial port and will need to interface with Widnows API and need to include windows.h ...

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.

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<uint8_t, bool>(params); \ fn<uint8_t, char>(...

how to organize fixture data and access them from tests in C/C++

How do I compute the path to data fixtures files in test code, given: test/{main.cpp,one_test.cpp,two_test.cpp} compilation done in build/ test/fixtures/{conf_1.cfg} The problem I'm facing is as ...

Catch compiles fine with MinGW32, but I get Segmentation Fault

I decided to try writing tests with Catch. I am using MinGW32 in Windows. I used the example file define here (which I reproduce below for convenience): #define CATCH_CONFIG_MAIN // This tells Catch ...

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 ...

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 ...

Can I use Catch with boost/program_options.hpp?

I have a program that uses boost/program_options.hpp to process command line arguments. I want to add unit-tests to this program, and the Catch framework is very attractive. However, it seems to mess ...

How to bypass assert in unit test in Debug mode?

In a test case I would like to test a function which in debug mode generates an assertion for invalid input. This unfortunately stops Catch test runner. Is there any way to bypass this assertion so ...

Catch test case order

Can I guarantee the order of execution with multiple TEST_CASEs with Catch? I am testing some code using LLVM, and they have some despicable global state that I need to explicitly initialize. Right ...

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** ...

Catch Unit Test Ordering

I would like to use Catch to do unit testing on a C++ lib. However I need the most of the test cases to be run in an order. ie the library needs to be init in a certain way and then users logged in ...

Inter test dependencies

Is there a way to specify inter test dependencies in catch. For instance is test_a fails then don't run test_b. My reason for doing this is that we programatically generate very large test cases. We ...

Use C++ catch framework to verify assert statement

Is it possible to use the C++ CATCH framework to verify that an assert statement correctly identifies an invalid precondition? // Source code void loadDataFile(FILE* input) { assert(input != NULL); ...

Catch lib (unit testing) and CTest (CMake) integration

I'm looking for successful example of Catch CatchLib integration with CMake test (Ctest) . as I understand this is additional cmake script which has to parse application ouput? Did someone already ...

Exceptions and BDD in C++ - Catch library

I've been using Boost.Test so far but am now looking into using BDD with Catch instead, but I have some trouble figuring out a nice way of handling exceptions. Say I've got a test like this: SCENARIO(...

Test that two std::vectors are equal using CATCH C++ unit test framework

I an new to using CATCH, and I wondering how one would go about testing whether two std::vectors are equal. My very naive attempt is this: #define CATCH_CONFIG_MAIN #include "catch.hpp" #include <...

Catch Lib issue - anonymous-namespace redefinition. how to solve

I'm using Catch Lib for unit testing Previously, I tested a headers individually, and had no issue with TEST_CASEs but after final including all of these into the project I faced with a lot of ...

C++ Mocking Recommendation

I'd like to try testing using Catch, since I really liked the fact that it allows you to write tests like "stories". The problem is that it does not come with a mocking system included. So, I'm ...

cmake: including other scripts rules. which variables are available

I'm including AddCatch.cmake script include(AddCatch) to automate unit testing process with Catch-Lib. this module: clone Catch-Lib from github, enable_testing(), parses the source files of current ...

How can I allow vector to be passed to INFO(), CAPTURE(), WARN(), etc. while avoiding illegally extending the std namespace?

In Catch Unit Test v1.8.1, with gcc 6.2.0, I'm trying to conveniently output the contents of a vector when a test fails by passing the vector to INFO(...) or CAPTURE(...). To do so I'm overloading ...

Compare Vector of Doubles Using Catch

I'm using the Catch unit testing framework, and I'd like to compare a vector of doubles. This other answer suggests using Approx to compare floating point/double values, but this doesn't work for a ...

Test floating point std::vector witch C++ Catch

is there any possibility in Catch C++ Unit test framework to compare std::vectors that are floating point type based? I know that I can compare size of both containers and each element (using Approx) ...

C/C++ Project inluding folders containing separate build shells not able to include files from each other

I have a complex 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. a C++ build standard external ...

Dealing with optional tests

The absence of a way to skip a test in CATCH, Google Test and other frameworks (at least in the traditional sense, where you specify the reason for doing so and see it in the output) made me think if ...

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); ...

How to retrieve or print “Catch” info logging buffers?

Using the Catch single-include unit-tester, I have (passing) tests like this TEST_CASE ("sizes", "[metadata]" ) { INFO ( "The number is " << 42 ); REQUIRE (sizeof(some_struct) == 16); } ...

How call executable from nmake, check the return value

My company has a small amount of C++ code and it is built with NMake, which I do not know much about. I wanted to add some unit tests so I used Catch as it was simple to setup. I modified the NMake ...

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 ...

Good way to call overloaded const vs non-const method in C++ TDD?

All wrote some fancy container with iterators. So I have iterator begin() { } iterator end() { } const_iterator begin() const { } const_iterator end() const { } In test I instantiate container, ...

Good way to repeat a test, inserting an extra action?

I like the way Catch has nested hierarchies of tests, and it works through the combinations. It feels more natural than the setup/teardown of xUnit frameworks. I now have a set of tests. What I want ...

Catch not catching exception

I'm using Catch to write unit tests and came across a problem where my test fails because an exception is thrown, even though I use REQUIRE_THROWS_AS. This is my test: SECTION("Get column index for ...

Catch unit test library linking error

I am trying to use CATCH unit test suite linked below. https://github.com/philsquared/Catch However, I cannot succeed to make it right. The main.cpp and test.cpp are as follows. //main.cpp #define ...

How to perform Unit Testing on complicated functions

I have a class XYZ which has some function whivh I need to test using Catch Unit-testing. I am in a state of confusion what can be the possibility to test the function. Can anyone help on this? Test ...

String convertion of function expression with parameters in Catch assertion

If I run the following test witch Catch bool eq(int x, int y) { return x == y; } TEST_CASE("operator vs. function call") { int x = 1; int y = 2; CHECK(x == y); CHECK(eq(x, y)); } ...

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 ...

C++ Catch Framework Deal with C's assert?

I have unittests using the Phil Squared's Catch Testing framework in combination with some third party code that is using assert. During development it happens quiet often that through some bug ...
Translating... 0%