Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error setting up world results in successful exit #120

Open
rkennedy opened this issue Jun 8, 2015 · 0 comments
Open

Error setting up world results in successful exit #120

rkennedy opened this issue Jun 8, 2015 · 0 comments

Comments

@rkennedy
Copy link

rkennedy commented Jun 8, 2015

If a fixture has a setUpWorld method defined, and that method returns false, then the test runner will run no tests, and the program will terminate with exit status 0. The documentation doesn't actually say what happens when setUpWorld returns false, but I wouldn't expect a successful exit status.

Consider the following code:

#include <iostream>
#include <cxxtest/TestSuite.h>
#include <cxxtest/GlobalFixture.h>

class Fixture1: public CxxTest::GlobalFixture
{
public:
    bool setUpWorld() {
        std::clog << "Fixture1::setUpWorld about to return false" << std::endl;
        return false;
    }
};
static Fixture1 fixture1;

class Suite: public CxxTest::TestSuite
{
public:
    void testShouldFail() {
        TS_FAIL("This should never run.");
    }
};

I compiled and ran it as follows:

cxxtestgen --abort-on-fail --error-printer --have-std --have-eh test.h -o test.cpp
clang++ -Wall test.cpp
./a.out

Output is this:

Running cxxtest tests (1 test)Fixture1::setUpWorld about to return false

In <no suite>::<no test>:
/usr/local/include/cxxtest/RealDescriptions.cpp:5: Warning: Error setting up world
OK!

Furthermore, echo $? prints 0. The exit status and the OK! at the end of the output mean that any script running this test program will consider it successful even though it failed on setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant