Newest 'catch-unit-test' Questions

Q&A for professional and enthusiast programmers

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

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.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 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 ...
Translating... 0%