forked from skyscreamer/JSONassert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquickstart.html
More file actions
83 lines (74 loc) · 3.39 KB
/
quickstart.html
File metadata and controls
83 lines (74 loc) · 3.39 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
<!doctype html>
<html>
<head>
<title>JSONAssert - Write JSON Unit Tests with Less Code - Quickstart</title>
<meta name="description" content="Great for testing REST interfaces, JSONassert greatly simplifies testing JSON results in unit tests." />
<meta name="keywords" content="jsonassert,json unit test,rest unit test,json junit,rest junit" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link href="css/style.css" rel="stylesheet"/>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-33062731-1']);
_gaq.push(['_setDomainName', 'skyscreamer.org']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<header>
<h1>JSONassert</h1>
<h2>a <a href="http://skyscreamer.org">Skyscreamer</a> project</h2>
</header>
<br clear="all" />
<nav>
<ul>
<li><a class="intro" href="./">Introduction</a></li>
<li><a class="cookbook" href="cookbook.html">Cookbook</a></li>
<li><a class="quickstart" href="">Quickstart</a></li>
<li><a class="javadoc" href="apidocs/index.html">Javadoc</a></li>
<li><a class="download" href="https://github.com/skyscreamer/JSONassert/releases">Download</a></li>
<li><a class="contrib" href="https://github.com/skyscreamer/jsonassert"> </a></li>
</ul>
</nav>
<section>
<a name="intro"></a>
<h2>Quick Start</h2>
<p>To use, <a href="https://github.com/skyscreamer/JSONassert/releases">download and build the JAR</a> or
add the following to your project's pom.xml:</p>
<div class="example">
<blockquote>
<a><dependency></a><br/>
<a> <groupId>org.skyscreamer</groupId></a><br/>
<a> <artifactId>jsonassert</artifactId></a><br/>
<a> <version>1.5.0</version></a><br/>
<a></dependency></a><br/>
</blockquote>
</div>
<p>Syntax is simple, and similar to JUnit Assert:</p>
<div class="example">
<blockquote>
<a>JSONAssert.assertEquals(<span class="italics">expectedJSON</span>, <span class="italics">actualJSON</span>, <span class="italics">strictMode</span>);</a><br/>
</blockquote>
</div>
<p>Add JSONassert tests within existing JUnit tests, just like you would add a standard Assert:</p>
<div class="example">
<blockquote>
<a>@Test</a><br/>
<a>public void testGetUser() {</a><br/>
<a> Assert.assertTrue(_restService.isEnabled());</a><br/>
<a> String result = _restService.get("/user/123.json");</a><br/>
<a class="emphasize"> JSONAssert.assertEquals("{id:123,name:\"Joe\"}", result, false);</a><br/>
<a>}</a><br/>
</blockquote>
</div>
<p>It is recommended that you leave <span class="italics">strictMode</span>
off, so your tests will be less brittle.
Turn it on if you need to enforce a particular order for arrays, or if you want to
ensure that the actual JSON does not have any fields beyond what's expected.</p>
</section>
</body>
</html>