Gathering Statistics: Collecting

Learn about the collect function and how to use it in properties.

We'll cover the following

Collect

The collect(Value, PropertyResult) function allows us to gather the values of one specific metric per test and build stats out of all the runs that happened for a property. It’s special in that we need to use it to wrap the actual property result and add context to it. Let’s go through using the function and understanding how it works. The function takes two arguments, which are Value and PropertyResult.

Value represents the metric from which the statistics will be built. PropertyResult is the result of the property. The collect function takes both of these values and wraps them in a way that lets PropEr gather the metrics as well as validate the properties.

Get hands-on with 1200+ tech skills courses.