Introduction to Thinking in Properties

Get introduced to what we'll be going through in the chapter.

In the last chapter, we went over basic properties, including their syntax and generators that are available out of the box. We played with the biggest(List) function, ensuring it behaved properly. We should now have a good idea of what a property looks like and how to read it, but chances are we might not feel comfortable writing one on our own quite yet. Experience is key in writing properties. With consistent practice, the process should begin to feel natural. For the purposes of our lesson, though, we’ll try to speed the process up.

As we noticed in the previous chapter, writing good properties is challenging and requires more effort than writing standard tests. . In this chapter, we’ll go through techniques that transition from using the standard tests to thinking in properties that feel natural.

We’ll go over a few tips and tricks to help us figure out how to write decent enough properties in tricky situations. The tricks we are going to use are:

  1. Modeling
  2. Generalizing example tests
  3. Finding invariants
  4. Symmetric properties

Get hands-on with 1400+ tech skills courses.