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

Generate Scalacheck-Generators and Arbitraries #106

Open
diesalbla opened this issue Nov 30, 2018 · 1 comment
Open

Generate Scalacheck-Generators and Arbitraries #106

diesalbla opened this issue Nov 30, 2018 · 1 comment

Comments

@diesalbla
Copy link
Contributor

Many Scala projects use Scalacheck for property-based testing. In Scalacheck, to generate test cases one uses a special object or generator, an instance of type Gen[X], which generates values of class X that may cover as many corner cases as possible.

However, building Generators for complex data types, like nested records such as those that avrohugger generates, is a tiresome task. One common way to solve this is to use scalacheck-shapeless, but that is known to increase compile times unreasonably.

Since avrohugger knows how to generate complex case class from basic types, it may as well generate the generators for those. The purpose of this task is to incorporate into Avro-hugger a system to do just that. Since this would introduce a dependency on Scalacheck, we may want to keep this part of the code separate.

@julianpeeters
Copy link
Owner

This sounds great @diesalbla, thanks for the proposal. I agree this feature should be added.

In regards to where to put it, a separate module sounds does sound nice, however that may prove difficult given avrohugger's current design (specifically, I think an explicit model/intermediate representation would allow a typeclass based approach? It'd be nice to ditch the inheritance. And of course explicit effects would be nice).

In lieu of a refactor, I think the easiest way to add this feature might be to follow the existing pattern and add a field to the Generator constructor, I have in mind a flag that directs the generation of arbitraries in companion objects or a separate file, however I'd be very open to considering alternatives.

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