-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
288 lines (261 loc) · 19.8 KB
/
index.html
File metadata and controls
288 lines (261 loc) · 19.8 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Spock Framework - the enterprise-ready specification framework</title>
<meta name="description" content="Spock is an expressive testing and specification framework for Java and Groovy applications. Write highly readable, maintainable BDD-style tests with powerful mocking.">
<meta name="keywords" content="Spock Framework, Groovy, Java, Kotlin, JVM, testing, specification, BDD, Behavior-Driven Development, unit testing, mocking, JUnit, JUnit 5">
<meta name="author" content="Spock Framework Team">
<meta name="theme-color" content="#111827">
<link rel="canonical" href="https://spockframework.org/">
<meta name="robots" content="index, follow">
<link rel="icon" href="/spock-main-logo.svg" type="image/svg+xml">
<meta property="og:type" content="website">
<meta property="og:url" content="https://spockframework.org/">
<meta property="og:title" content="Spock Framework - the enterprise-ready specification framework">
<meta property="og:description" content="Spock is a testing, specification, and mocking framework for JVM developers that emphasizes readability and clarity. By blending BDD concepts and Groovy's concise syntax, Spock helps teams write tests that are easy to understand and enjoyable to maintain.">
<meta property="og:image" content="/spock-main-logo.svg">
<meta property="twitter:card" content="summary">
<meta property="twitter:url" content="https://spockframework.org/">
<meta property="twitter:title" content="Spock Framework - the enterprise-ready specification framework">
<meta property="twitter:description" content="Spock is a testing, specification, and mocking framework for JVM developers that emphasizes readability and clarity. By blending BDD concepts and Groovy's concise syntax, Spock helps teams write tests that are easy to understand and enjoyable to maintain.">
<meta property="twitter:image" content="/spock-main-logo.svg">
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin="anonymous">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet" crossorigin="anonymous">
</head>
<body class="leading-normal tracking-normal">
<section class="pt-24 pb-16 md:pt-32 md:pb-24 bg-gray-800">
<div class="container mx-auto px-6 text-center">
<div class="mb-8">
<img
src="spock-main-logo.svg"
alt="Spock Framework Logo"
class="h-64 w-auto mx-auto block logo-img">
</div>
<h1 class="text-4xl md:text-5xl lg:text-6xl font-bold mb-4 spock-blue-text">
Spock
</h1>
<p class="text-xl md:text-2xl text-gray-400 mb-8">
the enterprise-ready specification framework
</p>
<p class="max-w-3xl mx-auto text-lg text-gray-300 mb-12">
Spock is a testing, specification, and mocking framework for JVM developers that emphasizes readability and clarity.
By blending BDD concepts and Groovy's concise syntax, Spock helps teams write tests that are easy to understand and enjoyable to maintain.
</p>
</div>
</section>
<section class="py-16 md:py-24">
<div class="container mx-auto px-6 text-center">
<h2 class="text-3xl md:text-4xl font-bold mb-8 text-gray-100" data-aos="fade-up">Ready to Improve Your Testing?</h2>
<div class="flex flex-col sm:flex-row justify-center items-center space-y-4 sm:space-y-0 sm:space-x-4" data-aos="fade-up" data-aos-delay="200">
<a href="https://groovyconsole.dev/?g=groovy_4_0&gist=437e9026ff86d2d709c2c56eb7e2eef1#g8qcDpYAQE" target="_blank" class="cta-button cta-primary">
<i class="fa-solid fa-laptop-code"></i> Try it online
</a>
<a href="https://docs.spockframework.org" target="_blank" class="cta-button cta-tertiary">
<i class="fa-solid fa-book"></i> Read the Docs
</a>
<a href="https://github.com/spockframework/spock-example" target="_blank" class="cta-button cta-tertiary">
<i class="fa-solid fa-code"></i> Clone the Example Project
</a>
</div>
</div>
<div class="container mx-auto px-6 text-center spock-blue-text text-md additional-links flex flex-wrap justify-center items-center gap-y-2 pt-8" data-aos="fade-up" data-aos-delay="300">
<a href="https://spockframework.org/spock/javadoc/current" class="mx-3 hover-underline-animation"><i class="fa-brands fa-java"></i> JavaDoc</a> <span class="link-separator">|</span>
<a href="https://github.com/spockframework/spock" class="mx-3 hover-underline-animation"><i class="fa-brands fa-github fa-lg"></i> Code & Issues</a> <span class="link-separator">|</span>
<a href="https://stackoverflow.com/questions/tagged/spock" class="mx-3 hover-underline-animation"><i class="fa-brands fa-stack-overflow"></i> Q&A</a> <span class="link-separator">|</span>
<a href="https://github.com/spockframework/spock/discussions" class="mx-3 hover-underline-animation"><i class="fas fa-comments"></i> Discussions</a> <span class="link-separator">|</span>
<a href="https://gitter.im/spockframework/spock" class="mx-3 hover-underline-animation"><i class="fa-brands fa-gitter fa-lg"></i> Chat</a>
</div>
<div class="text-center mt-8 flex flex-wrap justify-center items-center gap-4" data-aos="fade-up" data-aos-delay="400">
<a href="https://search.maven.org/search?q=g:org.spockframework" target="_blank"><img src="https://img.shields.io/maven-central/v/org.spockframework/spock-core?style=for-the-badge&label=Latest%20Version&labelColor=374151&color=1562ae&versionSuffix=groovy-2.5" alt="Spock Latest Version for Groovy 2.5"></a>
<a href="https://search.maven.org/search?q=g:org.spockframework" target="_blank"><img src="https://img.shields.io/maven-central/v/org.spockframework/spock-core?style=for-the-badge&label=Latest%20Version&labelColor=374151&color=1562ae&versionSuffix=groovy-3.0" alt="Spock Latest Version for Groovy 3.0"></a>
<a href="https://search.maven.org/search?q=g:org.spockframework" target="_blank"><img src="https://img.shields.io/maven-central/v/org.spockframework/spock-core?style=for-the-badge&label=Latest%20Version&labelColor=374151&color=1562ae&versionSuffix=groovy-4.0" alt="Spock Latest Version for Groovy 4.0"></a>
<a href="https://search.maven.org/search?q=g:org.spockframework" target="_blank"><img src="https://img.shields.io/maven-central/v/org.spockframework/spock-core?style=for-the-badge&label=Latest%20Version&labelColor=374151&color=1562ae&versionSuffix=groovy-5.0" alt="Spock Latest Version for Groovy 5.0"></a>
</div>
</section>
<section class="py-16 md:py-24 bg-gray-800">
<div class="container mx-auto px-6">
<h2 class="text-3xl md:text-4xl font-bold text-center mb-16 text-gray-100" data-aos="fade-up">
Why Choose Spock?
</h2>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-8">
<div data-aos="fade-up" data-aos-delay="100">
<div class="feature-card h-full">
<div><i class="fas fa-receipt spock-blue-text"></i></div>
<h3 class="text-xl font-semibold text-gray-100 mb-2">Expressive Specifications</h3>
<p class="text-gray-300">Write tests that are easy to read and understand, even for
non-programmers.</p>
</div>
</div>
<div data-aos="fade-up" data-aos-delay="200">
<div class="feature-card h-full">
<div><i class="fas fa-masks-theater spock-blue-text"></i></div>
<h3 class="text-xl font-semibold text-gray-100 mb-2">Powerful Mocking</h3>
<p class="text-gray-300">Create flexible and powerful mocks and stubs with built-in support.</p>
</div>
</div>
<div data-aos="fade-up" data-aos-delay="300">
<div class="feature-card h-full">
<div><i class="fas fa-vial-circle-check spock-blue-text"></i></div>
<h3 class="text-xl font-semibold text-gray-100 mb-2">JUnit Platform</h3>
<p class="text-gray-300">Seamless integration with JUnit 5+ and build tools.</p>
</div>
</div>
<div data-aos="fade-up" data-aos-delay="400">
<div class="feature-card h-full">
<div><i class="fas fa-table-cells spock-blue-text"></i></div>
<h3 class="text-xl font-semibold text-gray-100 mb-2">Data-Driven Testing</h3>
<p class="text-gray-300">Easily run the same test with different sets of data.</p>
</div>
</div>
<div data-aos="fade-up" data-aos-delay="500">
<div class="feature-card h-full">
<div><i class="fas fa-star spock-blue-text"></i></div>
<h3 class="text-xl font-semibold text-gray-100 mb-2">Groovy DSL</h3>
<p class="text-gray-300">Leverage the power and flexibility of the Groovy language.</p>
</div>
</div>
<div data-aos="fade-up" data-aos-delay="600">
<div class="feature-card h-full">
<div><i class="fas fa-circle-check spock-blue-text"></i></div>
<h3 class="text-xl font-semibold text-gray-100 mb-2">Built-in Matchers</h3>
<p class="text-gray-300">Use a rich set of matchers to verify expectations with clarity.</p>
</div>
</div>
</div>
</div>
</section>
<section class="py-16 md:py-24">
<div class="container mx-auto px-6">
<h2 class="text-3xl md:text-4xl font-bold text-center mb-12 text-gray-100" data-aos="fade-up">
See How Readable Tests Can Be
</h2>
<div class="max-w-3xl mx-auto" data-aos="fade-up" data-aos-delay="100">
<pre><code class="language-groovy"><span class="comment">// CalculatorSpec.groovy</span>
<span class="keyword">import</span> spock.lang.Specification
<span class="keyword">class</span> <span class="class-name">CalculatorSpec</span> <span class="keyword">extends</span> Specification {
<span class="keyword">def</span> <span class="string">"Test calculate method: #a #operation #b = #expectedResult"</span>() {
<span class="keyword">given:</span> <span class="comment">"A calculator instance"</span>
<span class="keyword">def</span> calculator = <span class="keyword">new</span> <span class="class-name">Calculator</span>()
<span class="keyword">expect:</span> <span class="comment">"The calculation should match the expected value"</span>
calculator.calculate(a, b, operation) == expectedResult
<span class="keyword">where:</span> <span class="comment">"Define test data"</span>
a | b | operation || expectedResult
<span class="number">1</span> | <span class="number">2</span> | <span class="string">"+"</span> || <span class="number">3</span>
<span class="number">5</span> | <span class="number">3</span> | <span class="string">"-"</span> || <span class="number">2</span>
<span class="number">4</span> | <span class="number">2</span> | <span class="string">"*"</span> || <span class="number">8</span>
<span class="number">10</span> | <span class="number">2</span> | <span class="string">"/"</span> || <span class="number">5</span>
<span class="number">-1</span> | <span class="number">1</span> | <span class="string">"+"</span> || <span class="number">0</span>
<span class="number">1</span> | <span class="number">-1</span> | <span class="string">"-"</span> || <span class="number">2</span>
<span class="number">-2</span> | <span class="number">-2</span> | <span class="string">"*"</span> || <span class="number">4</span>
<span class="number">-4</span> | <span class="number">-2</span> | <span class="string">"/"</span> || <span class="number">2</span>
<span class="number">1</span> | <span class="number">1</span> | <span class="string">"+"</span> || <span class="number">42</span> <span class="comment">// A failing test case</span>
}
<span class="keyword">def</span> <span class="string">"Test calculate method with division by zero"</span>() {
<span class="keyword">given:</span> <span class="comment">"A calculator instance"</span>
<span class="keyword">def</span> calculator = <span class="keyword">new</span> <span class="class-name">Calculator</span>()
<span class="keyword">when:</span> <span class="comment">"Perform division by zero"</span>
calculator.calculate(<span class="number">10</span>, <span class="number">0</span>, <span class="string">"/"</span>)
<span class="keyword">then:</span> <span class="comment">"An IllegalArgumentException is thrown"</span>
<span class="keyword">def</span> exception = thrown(<span class="class-name">IllegalArgumentException</span>)
<span class="keyword">and:</span> <span class="comment">"The exception message is correct"</span>
exception.message == <span class="string">"Cannot divide by zero"</span>
}
<span class="keyword">def</span> <span class="string">"Test calculate method with invalid operation"</span>() {
<span class="keyword">given:</span> <span class="comment">"A calculator instance"</span>
<span class="keyword">def</span> calculator = <span class="keyword">new</span> <span class="class-name">Calculator</span>()
<span class="keyword">when:</span> <span class="comment">"Perform calculation with invalid operation"</span>
calculator.calculate(<span class="number">1</span>, <span class="number">2</span>, <span class="string">"**"</span>)
<span class="keyword">then:</span> <span class="comment">"An IllegalArgumentException is thrown"</span>
<span class="keyword">def</span> exception = thrown(<span class="class-name">IllegalArgumentException</span>)
<span class="keyword">and:</span> <span class="comment">"The exception message is correct"</span>
exception.message == <span class="string">"Invalid operation: **"</span>
}
}
<span class="comment">// Calculator.groovy</span>
<span class="keyword">class</span> <span class="class-name">Calculator</span> {
<span class="comment"> /**
* Performs arithmetic operations on two integers.
*
* <span class="annotation">@param</span> a The first integer.
* <span class="annotation">@param</span> b The second integer.
* <span class="annotation">@param</span> operation The operation to perform (+, -, *, /).
* <span class="annotation">@return</span> The result of the operation.
* <span class="annotation">@throws</span> IllegalArgumentException if the operation is invalid or division by zero is attempted.
*/</span>
<span class="keyword">int</span> calculate(<span class="keyword">int</span> a, <span class="keyword">int</span> b, <span class="class-name">String</span> operation) {
<span class="keyword">switch</span> (operation) {
<span class="keyword">case</span> <span class="string">"+"</span>: <span class="keyword">return</span> a + b
<span class="keyword">case</span> <span class="string">"-"</span>: <span class="keyword">return</span> a - b
<span class="keyword">case</span> <span class="string">"*"</span>: <span class="keyword">return</span> a * b
<span class="keyword">case</span> <span class="string">"/"</span>:
<span class="keyword">if</span> (b == <span class="number">0</span>) {
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="class-name">IllegalArgumentException</span>(<span class="string">"Cannot divide by zero"</span>)
}
<span class="keyword">return</span> a / b
<span class="keyword">default</span>:
<span class="keyword">throw</span> <span class="keyword">new</span> <span class="class-name">IllegalArgumentException</span>(<span class="string">"Invalid operation: "</span> + operation)
}
}
<span class="class-name">String</span> toString() {
<span class="keyword">return</span> <span class="string">"Calc"</span>
}
}
</code></pre>
<p class="text-center text-gray-400 mt-6" data-aos="fade-up" data-aos-delay="200">
Spock's clear <code class="inline-code">given:</code>, <code class="inline-code">when:</code>, <code class="inline-code">then:</code> blocks make understanding test logic intuitive.
</p>
<div class="mt-12" data-aos="fade-up" data-aos-delay="500">
<h3 class="text-xl font-semibold text-center mb-4 text-gray-100">Example Test Output:</h3>
<pre>╷
└─ Spock ✔
└─ CalculatorSpec ✔
├─ Test calculate method: #a #operation #b = #expectedResult ✔
│ ├─ Test calculate method: 1 + 2 = 3 ✔
│ ├─ Test calculate method: 5 - 3 = 2 ✔
│ ├─ Test calculate method: 4 * 2 = 8 ✔
│ ├─ Test calculate method: 10 / 2 = 5 ✔
│ ├─ Test calculate method: -1 + 1 = 0 ✔
│ ├─ Test calculate method: 1 - -1 = 2 ✔
│ ├─ Test calculate method: -2 * -2 = 4 ✔
│ ├─ Test calculate method: -4 / -2 = 2 ✔
│ └─ Test calculate method: 1 + 1 = 42 ✘ Condition not satisfied:
│
│ calculator.calculate(a, b, operation) == expectedResult
│ | | | | | | |
│ Calc 2 1 1 + | 42
│ false
├─ Test calculate method with division by zero ✔
└─ Test calculate method with invalid operation ✔</pre>
</div>
</div>
</div>
<div class="flex flex-col sm:flex-row justify-center items-center space-y-4 sm:space-y-0 sm:space-x-4 mt-8" data-aos="fade-up" data-aos-delay="800">
<a href="https://groovyconsole.dev/?g=groovy_4_0&gist=437e9026ff86d2d709c2c56eb7e2eef1#g8qcDpYAQE" target="_blank" class="cta-button cta-primary">
<i class="fa-solid fa-laptop-code"></i> Try it online
</a>
</div>
</section>
<section class="py-16 bg-gray-800">
<div class="container mx-auto px-6">
<h3 class="text-3xl md:text-4xl font-bold text-center text-gray-100" data-aos="fade-up">
Follow Us on
</h3>
<div class="container mx-auto px-6 text-center spock-blue-text text-md additional-links flex flex-wrap justify-center items-center gap-y-2 pt-8" data-aos="fade-up" data-aos-delay="100">
<a href="https://fosstodon.org/@spockframework" class="mx-3 hover-underline-animation"><i class="fa-brands fa-mastodon"></i> @spockframework</a> <span class="link-separator">|</span>
<a href="https://bsky.app/profile/spockframework.org" class="mx-3 hover-underline-animation"><i class="fa-brands fa-bluesky"></i> spockframework.org</a> <span class="link-separator">|</span>
<a href="https://x.com/SpockFramework" class="mx-3 hover-underline-animation"><i class="fa-brands fa-x-twitter"></i> @spockframework</a> <span class="link-separator">|</span>
<a href="https://github.com/spockframework/spock" class="mx-3 hover-underline-animation"><i class="fa-brands fa-github fa-lg"></i> spockframework/spock</a>
</div>
</div>
</section>
<footer class="py-8 text-center text-gray-400 text-sm">
<div class="container mx-auto px-6">
© 2025 Spock Framework Team. All rights reserved.
</div>
</footer>
<script type="module" src="src/main.ts"></script>
</body>
</html>