Debian Codegraph @

website/content/2016-04-16-the-purpose-of-hypothesis.md

raw
1 ---
2 tags: writing-good-software, principles, non-technical
3 date: 2016-04-16 12:00
4 title: The Purpose of Hypothesis
5 author: drmaciver
6 ---
7
8 What is Hypothesis for?
9
10 From the perspective of a user, the purpose of Hypothesis is to make it easier for you
11 to write better tests.
12
13 From my perspective as the primary author, that is of course also *a* purpose of Hypothesis.
14 I write a lot of code, it needs testing, and the idea of trying to do that without Hypothesis
15 has become nearly unthinkable.
16
17 But, on a large scale, the true purpose of Hypothesis is to drag the world kicking and screaming
18 into a new and terrifying age of high quality software.
19
20 <!--more-->
21
22 Software is everywhere. We have built a civilization on it, and it's only getting more prevalent
23 as more services move online and embedded and "internet of things" devices become cheaper and
24 more common.
25
26 Software is also terrible. It’s buggy, it's insecure, and it's rarely well thought out.
27
28 This combination is clearly a recipe for disaster.
29
30 The state of software testing is even worse. It’s uncontroversial at this point that you *should*
31 be testing your code, but it's a rare codebase whose authors could honestly claim that they feel
32 its testing is sufficient.
33
34 Much of the problem here is that it’s too hard to write good tests. Tests take up a vast quantity
35 of development time, but they mostly just laboriously encode exactly the same assumptions and
36 fallacies that the authors had when they wrote the code, so they miss exactly the same bugs that
37 you missed when they wrote the code.
38
39 Meanwhile, there are all sorts of tools for making testing better that are basically unused, or
40 used in only specialised contexts. The original Quickcheck is from 1999 and the majority of
41 developers have not even heard of it, let alone used it. There are a bunch of half-baked
42 implementations for most languages, but very few of them are worth using. More recently, there
43 are many good tools applied to specialized problems, but very little that even attempts, let
44 alone succeeds, to help general purpose testing.
45
46 The goal of Hypothesis is to fix this, by taking research level ideas and applying solid
47 engineering to them to produce testing tools that are both powerful *and* practical, and
48 are accessible to everyone..
49
50 Many of the ideas that Hypothesis is built on are new. Many of them are not. It doesn't matter.
51 The purpose of Hypothesis is not to produce research level ideas. The purpose of Hypothesis is
52 to produce high quality software by any means necessary. Where the ideas we need exist, we
53 will use them. Where they do not, we will invent them.
54
55 If people aren't using advanced testing tools, that's a bug. We should find it and fix it.
56
57 Fortunately, we have this tool called Hypothesis. It's very good at finding bugs. But this
58 one it can also fix.