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

[question] Why are SUBCASEs executed only once when within a function called multiple times? #88

Closed
andreaplanet opened this issue Sep 1, 2017 · 1 comment

Comments

@andreaplanet
Copy link

andreaplanet commented Sep 1, 2017

Description

SUBCASE's are executed only once if within a function.
I missed the documentation where it is described.

Steps to reproduce

void MyTestCase(int n)
{
	SUBCASE("") { cout << "MyTestCase:" << n << endl; }
}


TEST_CASE("lots of nested subcases") {
	cout << endl << "root" << endl;
	MyTestCase(1);
	MyTestCase(2);
}

Expected output:

root
MyTestCase:1
MyTestCase:2

Got output:

root
MyTestCase:1

Extra information

  • doctest version: 1.2.1
  • Operating System: Ubuntu 17.04 64 bit
  • Compiler+version: g++ (Ubuntu 6.3.0-12ubuntu2) 6.3.0 20170406

and

  • Operating System: Windows 10
  • Compiler+version: Visual Studio 2017 Community Edition
@andreaplanet andreaplanet changed the title SUBCASEs are executed only once when within a template function SUBCASEs are executed only once when within a function Sep 1, 2017
@onqtam onqtam changed the title SUBCASEs are executed only once when within a function [question] Why are SUBCASEs executed only once when within a function? Sep 4, 2017
@onqtam onqtam changed the title [question] Why are SUBCASEs executed only once when within a function? [question] Why are SUBCASEs executed only once when within a function called multiple times? Sep 4, 2017
@onqtam
Copy link
Member

onqtam commented Sep 4, 2017

Hi!

This is the expected behavior. Doctest cannot (easily) know from what callstack a subcase is defined - from the point of view of the framework there is only one subcase found while executing the test case and it is uniquely identified by the file and line it is written at (using __FILE__ and __LINE__) and by its name.

What exactly is your testing scenario? Perhaps the subcases can be extracted from the separate function?

Perhaps I should improve the documentation :)

@onqtam onqtam closed this as completed Sep 11, 2017
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

2 participants