-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.html
More file actions
125 lines (105 loc) · 8.4 KB
/
index.html
File metadata and controls
125 lines (105 loc) · 8.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Expectations by jaycfields</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<script src="javascripts/scale.fix.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper">
<header>
<h1 class="header">Expectations</h1>
<p class="header">a minimalist's unit testing framework</p>
<ul>
<li><a class="buttons" href="index.html">Home</a></li>
<li><a class="buttons" href="installing.html">Installing</a></li>
<li><a class="buttons" href="introduction.html">Introduction</a></li>
<li><a class="buttons" href="advanced.html">Advanced</a></li>
<li><a class="buttons" href="collections.html">Collections</a></li>
<li><a class="buttons" href="templating.html">Expect More</a></li>
<li><a class="buttons" href="odds-ends.html">Odds & Ends</a></li>
<li><a class="buttons" href="in-context.html">Around Each</a></li>
<li><a class="buttons" href="before-run-hook.html">Around Suite</a></li>
<li><a class="buttons" href="state-warnings.html">State Warnings</a></li>
<li><a class="buttons" href="redef-state.html">Redef State</a></li>
<li><a class="buttons" href="interactions.html">Side Effects</a></li>
<li><a class="buttons" href="freeze-time.html">Freeze Time</a></li>
<li><a class="buttons" href="env-tweaks.html">ENV Tweaks</a></li>
<li><a class="buttons" href="emacs-tweaks.html">emacs Tweaks</a></li>
<li><a class="buttons" href="clojure-test.html">clojure.test</a></li>
<li><a class="buttons github" href="https://github.com/clojure-expectations/expectations">View On GitHub</a></li>
</ul>
<p class="header">This project is maintained by <a class="header name" href="https://github.com/seancorfield">seancorfield</a> and <a class="header name" href="https://github.com/jaycfields">jaycfields</a></p>
</header>
<section>
<h1>
<a name="expectations" class="anchor" href="#expectations"><span class="octicon octicon-link"></span></a>expectations</h1>
<blockquote>
<p>adding signal, removing noise</p>
</blockquote>
<p>
this is documentation for the "classic" expectations library
(considered stable and "in maintenance mode" at this point).
it uses its own set of tooling and is not compatible with clojure.test-based
tooling.
there is a very actively-maintained variant of expectations that
<em>is</em> compatible with clojure.test and its tooling:
<a href="https://cljdoc.org/d/com.github.seancorfield/expectations/">expectations.clojure.test</a>
(see also <a href="clojure-test.html">clojure.test compatibility</a>)
</p>
<h2>
<a name="10-second-example-inferred-testing-demo" class="anchor" href="#10-second-example-inferred-testing-demo"><span class="octicon octicon-link"></span></a>10 second example</h2>
<div class="highlight"><pre><span class="c1">;; expectations uses the format (expect expected actual) for all tests</span>
<span class="c1">;; (equality, expected exception, regex matching, interactions, etc).</span>
<span class="c1">;; use expectations to test equality</span>
<span class="p">(</span><span class="nf">expect</span> <span class="mi">1</span> <span class="mi">1</span><span class="p">)</span>
<span class="p">(</span><span class="nf">expect</span> <span class="s">"foo"</span> <span class="s">"foo"</span><span class="p">)</span>
<span class="c1">;; test if the regex is in a string</span>
<span class="p">(</span><span class="nf">expect</span> <span class="o">#</span><span class="s">"foo"</span> <span class="s">"boofooar"</span><span class="p">)</span>
<span class="c1">;; does the form throw an expected exception</span>
<span class="p">(</span><span class="nf">expect</span> <span class="nv">ArithmeticException</span> <span class="p">(</span><span class="nb">/ </span><span class="mi">12</span> <span class="mi">0</span><span class="p">))</span>
<span class="c1">;; expect a value in a collection (k/v for maps)</span>
<span class="p">(</span><span class="nf">expect</span> <span class="p">{</span><span class="ss">:foo</span> <span class="mi">1</span><span class="p">}</span> <span class="p">(</span><span class="nf">in</span> <span class="p">{</span><span class="ss">:foo</span> <span class="mi">1</span> <span class="ss">:cat</span> <span class="mi">4</span><span class="p">}))</span>
<span class="p">(</span><span class="nf">expect</span> <span class="ss">:foo</span> <span class="p">(</span><span class="nf">in</span> <span class="o">#</span><span class="p">{</span><span class="ss">:foo</span> <span class="ss">:bar</span><span class="p">}))</span>
<span class="p">(</span><span class="nf">expect</span> <span class="ss">:foo</span> <span class="p">(</span><span class="nf">in</span> <span class="p">[</span><span class="ss">:bar</span> <span class="ss">:foo</span><span class="p">]))</span>
<span class="c1">;; expect a function to return a truthy value given the actual argument</span>
<span class="p">(</span><span class="nf">expect</span> <span class="nv">empty?</span> <span class="p">(</span><span class="nf">list</span><span class="p">))</span>
</pre></div>
<h2>
<a name="installing" class="anchor" href="#installing"><span class="octicon octicon-link"></span></a>More</h2>
<p>consistent syntax is very important to expectations, but there are additional features that focus on increasing signal and reducing noise.<p>
<ul>
<li> simply require expectations and your tests will be run on JVM shutdown, no call to any 'run' function is necessary.</li>
<li> stacktraces are trimmed of clojure library lines and java.lang lines</li>
<li> error & failure messages provide much more than 'expected' and 'actual' values. Strings, Maps, Sets, and Lists are all compared at a deeper level, allowing faster pinpointing of the reason for the failure.</li>
</ul>
<p>expectations is simple to get started with, but also very feature rich. Please click <a href="introduction.html">Introduction</a> to begin exploring it's many features<p>
<h2>
<a name="credit" class="anchor" href="#credit"><span class="octicon octicon-link"></span></a>Credit</h2>
<p>Expectations is based on clojure.test. clojure.test is distributed under the Eclipse license, with
ownership assigned to Rich Hickey.</p>
<h2>
<a name="license" class="anchor" href="#license"><span class="octicon octicon-link"></span></a>License</h2>
<p>Copyright (c) 2010, Jay Fields
All rights reserved.</p>
<p>Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:</p>
<ul>
<li><p>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</p></li>
<li><p>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</p></li>
<li><p>Neither the name Jay Fields nor the names of the contributors may be used to endorse or promote products derived from this software without specific prior written permission.</p></li>
</ul><p>THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.</p>
</section>
<footer>
<p><small>Hosted on <a href="https://pages.github.com">GitHub Pages</a> using the Dinky theme</small></p>
</footer>
</div>
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
</body>
</html>