banditcpp / bandit

Human-friendly unit testing for C++11
https://banditcpp.github.io/bandit/
Other
259 stars 37 forks source link

--only doesn't work the same way in Qt Creator debugger #138

Closed MartinDelille closed 4 years ago

MartinDelille commented 5 years ago

I noticed a difference with the --only parameter when running bandit in Qt Creator debugger.

Given the following tests:

go_bandit([]() {
    describe("engine", []() {
        it("is empty", [&]() {
            AssertThat(true, IsTrue());
        });

        describe("bmp", [&]() {
            it("open", [&]() {
                AssertThat(false, IsTrue());
            });

            it("display first frame", [&]() {
                AssertThat(false, IsTrue());
            });
        });
    });
});

If I run it with --only="is empty" parameter, I have the following expected output:

./BanditTest --only="is empty"                                                                                                                  Fri 
.SS
Success!

Unfortunately, passing the same parameter to the debugger doesn't behave in the same way:

.S
F
There were failures!

engine bmp display first frame:
../../../../test/qt/BanditTest/main.cpp:18: Expected: true
Actual: 0

Test run complete. 2 tests run. 1 succeeded. 1 skipped. 1 failed.

Why is the spec engine bmp display first frame executed?

I put the corresponding code here: https://github.com/MartinDelille/BanditTest

Strangely this problem happens only in Qt Creator debugger (not when starting the debugger from the command line).

sbeyer commented 5 years ago

I have no installation of Qt Creator, so I can't test. But my simple guess is that Qt Creator does not interpret the space between "is" and "empty" correctly. Assuming that Qt Creator runs ./BanditTest --only=is, the first and the last test title match.

edit: What if you run --only=empty?

edit2: To work around this problem in cases where you need many words to get the right result, you can use multple --only arguments, like --only=is --only=empty.

MartinDelille commented 5 years ago

Yes using several --only arguments works indeed in both case.