Scalæ By the Bay has ended
Back To Schedule
Saturday, November 12 • 1:40pm - 2:00pm
Random Data Generation with ScalaCheck

Sign up or log in to save this to your schedule, view media, leave feedback and see who's attending!

ScalaCheck is a well-known library for property-base testing. However, property-base testing is not always possible when side effects are involved, for example when writing an integration test that involves data being stored in a database. When writing non-property-base tests, we often need to initialise some data and then verify some assertions on it. However, manual data generation can make our data biased and stop from spotting bugs in our code. Having our data generated randomly not only it would make our test less biased, but it will also make it a lot more readable by highlighting what part of our data are actually relevant in our test. In this talk we will discuss how to reuse some of the existing ScalaCheck code to generate random instances of given types and how these can be combined to generate random case classes. We will analyse the properties of a ScalaCheck generator and provide examples of how we can manipulate existing generators to meet our needs. Finally, we will show how random data generation can also be used in development to restore our data-driven-application in a particular state.

avatar for Daniela Sfregola

Daniela Sfregola

Blogger and Software Engineer, Daniela Tech LTD
Daniela Sfregola is a Software Consultant based in London, UK. She has worked as Java developer before moving towards Scala. She is an active contributor to the Scala Community and a passionate blogger at danielasfregola.com.

Saturday November 12, 2016 1:40pm - 2:00pm PST