-
Notifications
You must be signed in to change notification settings - Fork 106
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
Report on which sub-property failed #74
Comments
What you're seeing is also normal. What SwiftCheck is telling you is
SwiftCheck also offers a variety of combinators to make custom behavior (like what I think you're asking for) possible. But I think some combination of verbose, conjunction, and disjunction should suffice for your problem. |
I do see a bug in the pluralizer, tho. That will be fixed shortly. |
As for the matter of expensive objects in tests, it may be possible SwiftCheck is causing over-retains if you happen to capture things inside the testing block (which gets bandied around quite a bit of tree-mutations before actually being invoked). The natural solution to this is to use a smart-pointer-esque value type. Otherwise I can think of 2 other ways to help with this:
Or give forAll an explicit generator:
|
Thank you for taking the time to respond to this. I see in the comments now about how conjunction will mask lower failures. Going directly to disjunction though isn't very useful, since I want a failure if any of them fail the whole. Based on your comment it seems that to get that I have to make a convoluted combination of them (which I currently can't picture, sorry about that). Also, I'm only testing values right now, so it's not over-retains. It's simply lots of Dictionaries 😄. |
Try Vanilla QuickCheck isn't even designed to do what you ask, though ScalaCheck is (because they have a very different architecture from us). Though we have had similar thoughts at one point in time (see #41). |
Okay. That's a good band-aid, but given randomness, it might take a bit for it to happen again. In that case, I would instead take the inputs given and manually try each of the sub-properties until I saw which one was failing... which seems to fly in the face of the FIRST principle for tests, and really isn't something I would expect contributors to my project to try to figure out if they get a failing test case. Anyway, it does seem that I wasn't really doing anything wrong, this just isn't supported currently, in the way I want to use it. I would understand if no change will be made for it, it just seemed counter-intuitive that it didn't report which sub-property was failing (I feel in the conjunction case, regardless of what it is, if you gave it a label that means it's important enough to be reported on in the failure case). |
That seems a bit hyperbolic. Manual, here, looks like this
or even
Then you just take off the verboses for passing cases. Point is QuickCheck (and by extension, SwiftCheck) care about the test case as a piece of data, as a whole whose parts are simply parts contributing. You have all the tools you need to examine the sub-parts of a failing test already, it's just a matter of using the right combination to produce a passing test. |
I personally think that when a test fails I should be able to tell why it failed, without having to modify it. I can agree to disagree here though. So, I did exactly what you prescribed, and I think I ran into a different issue:
It doesn't seem to be outputting the label of the sub-property. Edit: Here is an example of it getting further:
(The 100% at the end still feels so weird to me.) |
SwiftCheck is rather bare-bones about it because you have access to quite a bit of the testing mechanism to produce custom output. Or perhaps the original authors were lazy, who knows? 😛 If you can find a way to make this work while still maintaining modularity, I'll merge it.
There is no sub-property here. |
Does that mean:
isn't bugged? Each entity had a label (via For the time being |
Hmph, that may be something that can be fixed. That's expected output from QuickCheck, but you're right: we have a chance to do it better here. I'll see what I can do. |
With the merge of #76 this can be closed. If you have anything further to add, or I managed to not fix anything, feel free to reopen it or another issue. |
I may be doing something wrong, but when I use sub properties and one of them fails, all I get in the output are the inputs used and the name of the parent property. For example:
will just say that "equatable" failed, instead of also telling me that "not-equate" failed:
If I get it to go past 1 test, it looks even weirder, saying 100% of the sub-properties passed?:
Basically, I feel it would be really valuable to know which sub-properties have failed. Sometimes custom arbitrary types are expensive to compute and it's easier to do many sub-properties off the same random values.
The text was updated successfully, but these errors were encountered: