What is Property Based Testing
  • What is Property Based Testing?
  • David R. MacIver
  • Saturday, May 14, 2016

I get asked this a lot, and I write property based testing tools for a living,
so you’d think I have a good answer to this, but historically I haven’t. This is
my attempt to fix that.
何度も質問されました。
今も利用できるプロパティベーステストのツールを書いたことから私が正解を知ってるいると思ってのことだと思うのですが、歴史的に見ても私は答えを知りません。
この文章はそういう状況を変えるための取り組みです。

Historically the definition of property based testing has been “The thing that
QuickCheck does”. As a working definition this has served pretty well, but the
problem is that it makes us unable to distinguish what the essential features of
property-based testing are and what are just accidental features that appeared
in the implementations that we’re used to.
プロパティベーステストの歴史的な定義は「QuickCheck のやっていること」となっています。
実用的な優れた定義ですが、プロパティベーステストの本質的なフィーチャーと実装に起因する意図しないフィーチャーの区別できないところは問題です。

As the author of a property based testing system which diverges quite a lot from
QuickCheck, this troubles me more than it would most people, so I thought I’d
set out some of my thoughts on what property based testing is and isn’t.
QuickCheck とはだいぶ違うプロパティベーステストシステムの作者にとっては結構な問題です。
だから、この文章で私にとってプロパティベーステストとは何であり、何でないのかを伝えたいのです。

This isn’t intended to be definitive, and it will evolve over time as my
thoughts do, but it should provide a useful grounding for further discussion.
There are essentially two ways we can draw a boundary for something like this:
We can go narrow or we can go wide. i.e. we can restrict our definitions to
things that look exactly like QuickCheck, or things that are in the same general
family of behaviour. My inclination is always to go wide, but I’m going to try
to rein that in for the purpose of this piece.
私の考えも将来的に変化していくとは思いますが、議論の土台として役に立つと思います。
何かの境界線を定めるには基本的な方法が2つあります。狭くするか広くするかです。たとえば、定義を QuickCheck 自体そのものとして決めることもできるし、基本的な振る舞いが同じになるものとして決めることもできます。
私は普段から定義を広くしておきたい人間ですが、ここでは当初の目的のためなるべく制限していきたいと思い明日。

But I’m still going to start by planting a flag. The following are not essential
features of property based testing:
まず、明確な開始点を決めましょう。
次の要素はプロパティベーステストの本質的なフィーチャーではありません。

  1. Referential Transparency 参照透過性
  1. Types 型システム
  1. Randomization ランダム化
  1. The use of any particular tool or library 特定のツールやライブラリを利用する前提

As evidence I present the following: