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

Test case passes even though subcase failed #149

Closed
marack opened this issue Sep 6, 2018 · 3 comments
Closed

Test case passes even though subcase failed #149

marack opened this issue Sep 6, 2018 · 3 comments

Comments

@marack
Copy link

marack commented Sep 6, 2018

Description

It seems that the overall result of a test case is dependent only on the result of the final subcase to run. This means that a test case can pass even though one of the subcases has failed.

Steps to reproduce

The following code results in a failing unit test suite as expected (okay):

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
TEST_CASE("test")
{
  SUBCASE("one") { CHECK(true); }
  SUBCASE("two") { CHECK(false); }
}
...
[doctest] test cases:      1 |      0 passed |      1 failed |      0 skipped
[doctest] assertions:      2 |      1 passed |      1 failed |
[doctest] Status: FAILURE!

However if we swap which subcase is failing we get a passing unit test suite (not okay):

#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "doctest.h"
TEST_CASE("test")
{
  SUBCASE("one") { CHECK(false); }
  SUBCASE("two") { CHECK(true); }
}
...
[doctest] test cases:      1 |      1 passed |      0 failed |      0 skipped
[doctest] assertions:      2 |      1 passed |      1 failed |
[doctest] Status: SUCCESS!

Extra information

  • doctest version: v2.0.0, master, dev
  • Operating System: Fedora 28
  • Compiler+version: gcc 8.1.1
@onqtam
Copy link
Member

onqtam commented Sep 13, 2018

Damn this seems like a major bug - thanks for reporting it!

I might have caused it when refactoring the internals between versions 1.2.8, 1.2.9 and 2.0.0 - so perhaps you can try with 1.2.8

Unfortunately I will have access to a computer after a month so until then I cant do anything.

@andijcr
Copy link

andijcr commented Sep 20, 2018

noticed the same bug. Seems a regression, i tested the 2.0.0, 1.2.8 and 1.2.9, and it appears only in the 2.0.0 release

onqtam added a commit that referenced this issue Oct 24, 2018
@onqtam
Copy link
Member

onqtam commented Oct 24, 2018

Hi!

I just fixed the bug and will release version 2.0.1 today. However I won't be able to attend to any other issues in the near month since I'm overwhelmed by work. Since this was an actual bug I felt it would be irresponsible of me to leave it unaddressed.

@onqtam onqtam closed this as completed Oct 24, 2018
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

3 participants