-
-
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
Preconditions #603
Comments
Yes, we programmers call them "functions" |
I don't think functions will help if @timonbaetz needs But with for (auto val : {"bar", "baz", "bazzz"}) {
CAPTURE(val);
Foo foo;
foo.setBar(val);
CHECKED_IF(foo.hasBar()) {
CHECK(foo.isValid());
}
} |
Thx @lightmare that is what I am doing right now (more or less) but i thought maybe there is a better way
Things get a little bit ugly when I need to change more that one member of foo or maybe call some other functions in one of the tests. Lets say i want to test foo after calling setBar, the i want to check foo after calling setBar() and some other function |
If I understand @lightmare's concern correctly it's that a In general this plays into the work I'm doing on Generators, which are more broadly part of a property-based testing approach (which this seems to be leaning towards). I did a big refactoring of the sections mechanism a while be in support of that - and have a basic version working well enough for a demo in a local repo. Unfortunately I've been out of time to move it forward recently, but hope to get it in before too long (I'm really keen to get Property-Based testing support in). |
I didn't even know the name could be dynamic :) |
Thx @philsquared, property based testing is what I was looking for |
Here is my favorite way: Note that this breaks down if you add more
Here it won't call setBar one time!
|
Is there a recommended way to execute the same set of checks with different preconditions?
Something like:
but without the code duplication?
The text was updated successfully, but these errors were encountered: