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

Support for jqwik #189

Open
pfichtner opened this issue Sep 13, 2021 · 14 comments
Open

Support for jqwik #189

pfichtner opened this issue Sep 13, 2021 · 14 comments
Assignees

Comments

@pfichtner
Copy link
Contributor

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?

@LarsEckart
Copy link
Contributor

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.

@LarsEckart LarsEckart self-assigned this Sep 14, 2021
@jlink
Copy link
Contributor

jlink commented Aug 3, 2022

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.

@LarsEckart
Copy link
Contributor

We currently get together on Mondays, 19:00 German time. If that suits you, I can send you an invite. :)

@jlink
Copy link
Contributor

jlink commented Aug 3, 2022

Sure. Next Monday would be my last opportunity before vacation time.

@LarsEckart
Copy link
Contributor

I sent the invite to [email protected]

@jlink
Copy link
Contributor

jlink commented Aug 3, 2022 via email

@LarsEckart
Copy link
Contributor

ApprovalTests now also detects test methods that are using jqwik. released as 18.0.0

01be1e0

e70a7d6

@jlink
Copy link
Contributor

jlink commented Aug 9, 2022

ApprovalTests now also detects test methods that are using jqwik. released as 18.0.0

01be1e0

e70a7d6

Even better. It now detects any test method that uses the JUnit Platform convention of having @Testable in its list of meta-annotations.

@jlink
Copy link
Contributor

jlink commented Aug 9, 2022

For real jqwik support, however, jqwik's lifecycle must be considered. I'll have a look into that.

@jlink
Copy link
Contributor

jlink commented Aug 10, 2022

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.

@pfichtner
Copy link
Contributor Author

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 pfichtner/testtypes#69

With PR 69 I purged the class mentioned and everything seems still to work fine using NamedEnvironment#withParameters

@jlink
Copy link
Contributor

jlink commented Aug 10, 2022

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?

@pfichtner
Copy link
Contributor Author

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?

Right, so it does. So I guess this is what you want to prevent 😄

@jlink
Copy link
Contributor

jlink commented Aug 10, 2022

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.

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

3 participants