Support for jqwik
With #133 I suggested approvals to be working with jqwik but it doesn't (approvals version 12.1.1). Only after adding jqwik's Property class to AttributeStackSelector's classNames my example test worked. Did I miss something?
We ended up showing @ragunathjawahar how to write the same test using CombinationApprovals, and thus did not add support for jqwik (yet). I'll bring the topic up next time when we maintainers get together.
I'd also love to see jqwik support. I'd also be willing to contribute it.
Is there a way to enhance framework support as some kind of plug-in? This could be the first step before getting it into the core of ApprovalTests.
We currently get together on Mondays, 19:00 German time. If that suits you, I can send you an invite. :)
Sure. Next Monday would be my last opportunity before vacation time.
I sent the invite to [email protected]
Thanks.
Am Mi., 3. Aug. 2022 um 11:59 Uhr schrieb Lars Eckart < @.***>:
I sent the invite to @.***
— Reply to this email directly, view it on GitHub https://github.com/approvals/ApprovalTests.Java/issues/189#issuecomment-1203739414, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAZMAISXMYHEKLUB4IUFG3VXI7G5ANCNFSM5D6ZLSJA . You are receiving this because you commented.Message ID: @.***>
ApprovalTests now also detects test methods that are using jqwik. released as 18.0.0
https://github.com/approvals/ApprovalTests.Java/commit/01be1e0e292f16851d316ad16233d40201946a4d
https://github.com/approvals/ApprovalTests.Java/commit/e70a7d6c3853a6830a5008e6b185bca4c0a6b7da
ApprovalTests now also detects test methods that are using jqwik. released as 18.0.0
Even better. It now detects any test method that uses the JUnit Platform convention of having @Testable in its list of meta-annotations.
For real jqwik support, however, jqwik's lifecycle must be considered. I'll have a look into that.
I played around a bit and a first approach ended up using a per property lifecycle:
/**
* Using this handmade lifecycle will check all values at the end,
* and only if the property succeeds otherwise.
*/
@Property(tries = 11, seed = "42")
@PerProperty(JqwikApprovals.class)
void strings(@ForAll @StringLength(5) @AlphaChars String s) {
JqwikApprovals.verify(s);
}
It's not the best and most generic approach yet, but I think it proves that the approvals idea can be used within property-based testing.
I played around a bit and a first approach ended up using a per property lifecycle:
/** * Using this handmade lifecycle will check all values at the end, * and only if the property succeeds otherwise. */ @Property(tries = 11, seed = "42") @PerProperty(JqwikApprovals.class) void strings(@ForAll @StringLength(5) @AlphaChars String s) { JqwikApprovals.verify(s); }It's not the best and most generic approach yet, but I think it proves that the approvals idea can be used within property-based testing.
Just for reference, I have a small demo project for different test types.
Before the release of approvals 18.0.0 I used an adapted copy of AttributeStackSelector to get approvals work with jqwik, see https://github.com/pfichtner/testtypes/pull/69
With PR 69 I purged the class mentioned and everything seems still to work fine using NamedEnvironment#withParameters
With PR 69 I purged the class mentioned and everything seems still to work fine using
NamedEnvironment#withParameters
I assume this creates a file for each try?
With PR 69 I purged the class mentioned and everything seems still to work fine using
NamedEnvironment#withParametersI assume this creates a file for each try?
Right, so it does. So I guess this is what you want to prevent 😄
Right, so it does. So I guess this is what you want to prevent 😄
In the ideal world I'd like both:
- a single file (my solution)
- early failure (your solution)
I wonder if there's a way to do both without rewriting a lot of the verification logic of ApprovalTests.