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

expose example compiler, or move to it's own package #651

Open
adrian-gierakowski opened this issue Aug 8, 2024 · 1 comment
Open

expose example compiler, or move to it's own package #651

adrian-gierakowski opened this issue Aug 8, 2024 · 1 comment

Comments

@adrian-gierakowski
Copy link

I find it useful for testing as it's output is more predictable than fast-check arbitraries

@sukovanej
Copy link
Owner

Hey, there is ExampleServer.makeSchema, tho I just noticed i has a wrong docstring. It takes a schema and outputs an example of the schema if specified by an annotation or it attempts to construct one.

Let me just point out that personally, I wouldn't use it instead of fast-check arbitraries for serious testing. It might be alright for some smoke tests, but it won't give you the same safety like a proper property-based testing using the fast-check. Instead, consider constraining your schemas in a way that only valid values are generated by the fast-check arbitraries. For example, in the past I wrote some property tests for a logic storing strings into a postgres and thanks to the fast-check producing various crazy edge case strings I found out it is not possible to store a string containing \0 byte into a TEXT column. The problem wasn't the fast-check producing these values but that my schema was allowing them. So I created a new schema for a "storable string" (using Schema.filter(...)) and as a result my tests started passing but also I actually forbidden these unacceptable strings to be passed from the user of my API.

I understand your use-case might be completely different and the test suite more complex in comparison to this relatively trivial example, but maybe fast-check is actually pointing out some gaps in your validations or maybe the test might be written little bit differently. 🙂

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

2 participants