-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
No way to run an individual section #327
Comments
Hi @wichert, I'm not quite sure what you mean by, "run a specific test method only". First what do you mean by "test method"? Do you mean a In both of those cases you can run just that test case by specifying it's name on the command line - so I'm presuming I've missed some nuance to what you're talking about (especially with the talk of temporary test cases). |
I guess I'm too used to writing Python tests, which makes me use the wrong terminology when dealing with Catch :( What I mean is: I want to be able to run an individual SECTION. Typically my tests are structured like this: TEST_CASE("Tokenizer", "[search]") {
SECTION("Constructors") {
SECTION("Default constructor") { }
SECTION("Copy constructor") { }
}
SECTION("Unicode handling") { }
} When I have a bug in the copy constructor I want to be able to run only the Copy constructor section of the Tokenizer test case. Since that is not possible I currently end up copying code around so I get this: TEST_CASE("XXX Copy constructor", "[DEBUG]") {
// Copy of Tokenizer->Copy constructor
}
TEST_CASE("Tokenizer", "[search]") {
SECTION("Constructors") {
SECTION("Default constructor") { }
SECTION("Copy constructor") {
// Old/original version of what is now in "XXX Copy constructor"
}
}
SECTION("Unicode handling") { }
} I then just run the tests for the DEBUG tag. Once I'm done I copy the code back to the original section and delete the temporary test case. |
Ah! I wondered if you meant sections. |
It would indeed be very useful to be able to use |
A fix to this issue would be very nice. Some of my test cases take a long time to run, and it would be useful to run a particular section in a test case. |
@vpicaver - you might be better off splitting longer runner tests (which are presumably not unit tests) into separate |
The SECTION helps me set up the problem and re-use code. I'll have to look into TEST_CASE_METHOD |
Yeah, that's what |
Okay cool, makes sense. Catch has saved me a bunch time, btw. |
This is actually in master now, albeit a bit limited, so I am going to close this. |
Since I'm working on the same issue on doctest I'd like to note that the following: TEST_CASE( "Test" ) {
cout << "root" << endl;
SECTION( "sa" ) {
cout << "sa" << endl;
SECTION( "sb" ) {
cout << "sb" << endl;
}
SECTION( "sc" ) {
cout << "sc" << endl;
}
}
SECTION( "sd" ) {
cout << "sd" << endl;
}
} when ran like this:
So it enters the test case 3 times - when in reality it should only once. Not sure this is worth fixing though... |
Hi @onqtam, |
@philsquared just did - in the dev branch, but mine is a bit different - see the associated issue Anyway I first noticed the behavior I reported here while implementing the filtering in doctest - then I moved the filtering up a bit inside of my Subcase constructor (analogous to Section in Catch) and I no longer re-enter the test case if all other subcases that were not traversed didn't match the filtering criteria |
When debugging I often want to run a specific test method only. This is currently not possible, so as a workaround I find myself often copying a test method to a new temporary test case. That works, but isn't very pleasant.
An option to allow tagging of test methods (and suites if #320 is implemented) in combination with a new option to the test runner to filter methods (
-m <filter>
perhaps?) would be much appreciated.The text was updated successfully, but these errors were encountered: