mardi 20 septembre 2016

How to bypass assert in unit test with Catch framework?

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 that the test runner keeps going ?

Here is my test case:

 SCENARIO("Simple test case", "[tag]") {
    GIVEN("some object") {
        MyObject myobject;

        WHEN("object is initialized with invalid data") {
            // method init generates an assertion when parameters are invalid
            bool result = myObject.init(nullptr, nullptr, nullptr, nullptr);
            REQUIRE(false == result);

            THEN("data processing can't be started") {
            }
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire