From 20ce3ba59c8f227b2eed88ca5953ea61e7bac26e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 16:28:08 +0200 Subject: [PATCH 01/29] Prototype new design --- index.html | 323 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 299 insertions(+), 24 deletions(-) diff --git a/index.html b/index.html index ac55cee..9d2c659 100644 --- a/index.html +++ b/index.html @@ -1,24 +1,299 @@ -Spock

Spock

the enterprise ready specification framework

DocumentationSourceIssuesChat

What is it?

-

Spock is a testing and specification framework for Java and Groovy applications. What makes it stand out from the crowd is its beautiful and highly expressive specification language. Thanks to its JUnit runner, Spock is compatible with most IDEs, build tools, and continuous integration servers. Spock is inspired from JUnit, RSpec, jMock, Mockito, Groovy, Scala, Vulcans, and other fascinating life forms.

-

How Do I Get Started?

-

Read ten reasons why Spock is for you, run your first spec in Groovy Web Console, fork the spock-example project, learn how to write a specification, or dive into the reference documentation.

-

Install

-

with Gradle

-
testImplementation "org.spockframework:spock-core:2.1-groovy-3.0"

with Maven:

-
<dependency>
-  <groupId>org.spockframework</groupId>
-  <artifactId>spock-core</artifactId>
-  <version>2.1-groovy-3.0</version>
-  <scope>test</scope>
-</dependency>

Where Are The Docs?

- -

How Can I Get Involved?

- -
Built with Compositor.io
+ + + + + + Spock Framework - Expressive Testing for Java & Groovy + + + + + + + + + +
+
+
+ Spock Framework Logo +
+ +

+ Write Beautiful & Expressive Tests +

+

+ Spock: The highly practical testing framework for Java and Groovy applications. +

+

+ Spock combines the power of Behavior-Driven Development (BDD) with an elegant Groovy-based syntax. + Write tests that are not only powerful but also highly readable and maintainable, making collaboration easier and development faster. +

+
+
+ +
+
+

+ See How Readable Tests Can Be +

+
+
import spock.lang.*
+
+class MathSpec extends Specification {
+
+    def "should add two numbers correctly"() {
+        given: "Setup preconditions"
+        int a = 5
+        int b = 3
+
+        when: "Perform the action under test"
+        int result = a + b
+
+        then: "Assert the expected outcome"
+        result == 8
+    }
+}
+
+

+ Spock's clear given:, when:, then: blocks make understanding test logic intuitive. +

+
+
+
+ +
+
+

+ Why Choose Spock? +

+
+
+

Expressive Specifications

+

Write tests that are easy to read and understand, even for non-programmers.

+
+
+

Powerful Mocking

+

Create flexible and powerful mocks and stubs with built-in support.

+
+
+

JUnit Runner

+

Seamless integration with JUnit runners and build tools.

+
+
+

Data-Driven Testing

+

Easily run the same test with different sets of data.

+
+
+

Groovy DSL

+

Leverage the power and flexibility of the Groovy language.

+
+
+

Built-in Matchers

+

Use a rich set of matchers to verify expectations with clarity.

+
+
+
+
+ +
+

Ready to Improve Your Testing?

+

+ Explore the documentation, check out examples, or get started right away. +

+ + +
+
+ +
+ +
+ + + + + + + + + From a2ced4141dac1340ae6bd0cc36337bbfa847b8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 17:44:22 +0200 Subject: [PATCH 02/29] design v2 --- index.html | 192 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 133 insertions(+), 59 deletions(-) diff --git a/index.html b/index.html index 9d2c659..f9dc186 100644 --- a/index.html +++ b/index.html @@ -144,6 +144,14 @@ box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); /* shadow-lg */ } + .feature-card svg { + height: 40px; + margin-bottom: 1rem; + fill: none; + stroke: var(--spock-blue); + stroke-width: 2; + } + /* Additional Links Separator */ .link-separator::after { content: '|'; @@ -170,48 +178,33 @@

- Write Beautiful & Expressive Tests + Spock

-

- Spock: The highly practical testing framework for Java and Groovy applications. -

- Spock combines the power of Behavior-Driven Development (BDD) with an elegant Groovy-based syntax. - Write tests that are not only powerful but also highly readable and maintainable, making collaboration easier and development faster. + 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 not only easy to understand but also enjoyable to maintain.

-
-
-

- See How Readable Tests Can Be -

-
-
import spock.lang.*
-
-class MathSpec extends Specification {
-
-    def "should add two numbers correctly"() {
-        given: "Setup preconditions"
-        int a = 5
-        int b = 3
-
-        when: "Perform the action under test"
-        int result = a + b
+
+

Ready to Improve Your Testing?

- then: "Assert the expected outcome" - result == 8 - } -} -
-

- Spock's clear given:, when:, then: blocks make understanding test logic intuitive. -

-
+ +
+

@@ -219,26 +212,32 @@

+

Expressive Specifications

Write tests that are easy to read and understand, even for non-programmers.

+

Powerful Mocking

Create flexible and powerful mocks and stubs with built-in support.

-

JUnit Runner

-

Seamless integration with JUnit runners and build tools.

+ +

JUnit Platform

+

Seamless integration with JUnit Platform and build tools.

+

Data-Driven Testing

Easily run the same test with different sets of data.

+

Groovy DSL

Leverage the power and flexibility of the Groovy language.

+

Built-in Matchers

Use a rich set of matchers to verify expectations with clarity.

@@ -246,38 +245,113 @@

Built-in Matchers

-
-

Ready to Improve Your Testing?

-

- Explore the documentation, check out examples, or get started right away. -

+
+

+ See How Readable Tests Can Be +

+
+
// CalculatorSpec.groovy
+import spock.lang.Specification
 
-    
- - Try it online - - - Read the Docs - - - Clone the Example Project - +class CalculatorSpec extends Specification { + + def "Test calculate method: #a #operation #b = #expectedResult"() { + given: "A calculator instance" + def calculator = new Calculator() + + when: "Perform the calculation" + int result = calculator.calculate(a, b, operation) + + then: "The result should match the expected value" + result == expectedResult + + where: "Define test data" + a | b | operation || expectedResult + 1 | 2 | "+" || 3 + 5 | 3 | "-" || 2 + 4 | 2 | "*" || 8 + 10 | 2 | "/" || 5 + -1 | 1 | "+" || 0 + 1 | -1 | "-" || 2 + -2 | -2 | "*" || 4 + -4 | -2 | "/" || 2 + } + + def "Test calculate method with division by zero"() { + given: "A calculator instance" + def calculator = new Calculator() + + when: "Perform division by zero" + calculator.calculate(10, 0, "/") + + then: "An IllegalArgumentException is thrown" + def exception = thrown(IllegalArgumentException) + + and: "The exception message is correct" + exception.message == "Cannot divide by zero" + } + + def "Test calculate method with invalid operation"() { + given: "A calculator instance" + def calculator = new Calculator() + + when: "Perform calculation with invalid operation" + calculator.calculate(1, 2, "**") + + then: "An IllegalArgumentException is thrown" + def exception = thrown(IllegalArgumentException) + + and: "The exception message is correct" + exception.message == "Invalid operation: **" + } +} + + +// Calculator.groovy +class Calculator { + /** + * Performs arithmetic operations on two integers. + * + * @param a The first integer. + * @param b The second integer. + * @param operation The operation to perform (+, -, *, /). + * @return The result of the operation. + * @throws IllegalArgumentException if the operation is invalid or division by zero is attempted. + */ + int calculate(int a, int b, String operation) { + switch (operation) { + case "+": return a + b + case "-": return a - b + case "*": return a * b + case "/": + if (b == 0) { + throw new IllegalArgumentException("Cannot divide by zero") + } + return a / b + default: + throw new IllegalArgumentException("Invalid operation: " + operation) + } + } +} +
+

+ Spock's clear given:, when:, then: blocks make understanding test logic intuitive. +

-
- +
-
-
+
+
© 2025 Spock Framework Team. All rights reserved.
From 8a8e916e9b4531b82be0f16e869678726e431526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 17:49:47 +0200 Subject: [PATCH 03/29] Add missing tag line --- index.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/index.html b/index.html index f9dc186..ac1f888 100644 --- a/index.html +++ b/index.html @@ -180,6 +180,9 @@

Spock

+

+ the enterprise ready specification framework +

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 not only easy to understand but also enjoyable to maintain. From ee7a311d2756889947306068560859cdb8ddc19a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 17:51:21 +0200 Subject: [PATCH 04/29] Fix link text --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index ac1f888..4fad483 100644 --- a/index.html +++ b/index.html @@ -349,7 +349,7 @@

Source Code Issue Tracker Discussions - Discussion Chat + Chat

From e2a93ec012fed31ee4898e32eead4253ed43ec57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 18:00:12 +0200 Subject: [PATCH 05/29] Add logo and .gitignore --- .gitignore | 1 + spock-main-logo.svg | 1 + 2 files changed, 2 insertions(+) create mode 100644 .gitignore create mode 100644 spock-main-logo.svg diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/spock-main-logo.svg b/spock-main-logo.svg new file mode 100644 index 0000000..5e732d1 --- /dev/null +++ b/spock-main-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file From 9e5cde1db263790e203556a6fcc20fb770fc6d32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 18:18:09 +0200 Subject: [PATCH 06/29] Polish blurb --- index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.html b/index.html index 4fad483..91cf2d8 100644 --- a/index.html +++ b/index.html @@ -185,7 +185,7 @@

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 not only easy to understand but also enjoyable to maintain. + By blending BDD concepts and Groovy's concise syntax, Spock helps teams write tests that are easy to understand and enjoyable to maintain.

From 16d2e6887f6964f1ec64e686cea66468fe8334e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 18:23:22 +0200 Subject: [PATCH 07/29] Move links section --- index.html | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/index.html b/index.html index 91cf2d8..e22bd8e 100644 --- a/index.html +++ b/index.html @@ -248,7 +248,17 @@

Built-in Matchers

-
+ +
+
+ +

See How Readable Tests Can Be

@@ -344,15 +354,6 @@

-
-
-
© 2025 Spock Framework Team. All rights reserved. From 30587e81b280103c5cbca8ed4a2bec9bab16f314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 18:25:28 +0200 Subject: [PATCH 08/29] Remove hover animation for links --- index.html | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index e22bd8e..50692cf 100644 --- a/index.html +++ b/index.html @@ -249,12 +249,12 @@

Built-in Matchers

-
-
@@ -248,17 +256,7 @@

Built-in Matchers

- -
-
- -
+

See How Readable Tests Can Be

From 9dcdbb1f36ca6ba9786dcfba77ffe02ca38cacf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 18:42:55 +0200 Subject: [PATCH 10/29] Fix link animations --- index.html | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index e9e5717..513ba3a 100644 --- a/index.html +++ b/index.html @@ -153,16 +153,11 @@ } /* Additional Links Separator */ - .link-separator::after { - content: '|'; + .link-separator { margin-left: 0.75rem; /* mx-3 */ margin-right: 0.75rem; /* mx-3 */ color: #4b5563; /* gray-600 */ } - .additional-links a:last-child .link-separator::after { - content: ''; /* Don't show separator after the last link */ - margin: 0; - } @@ -207,11 +202,11 @@

From 2e1dd5a25e95777be387c9f65c0e49105f13f71b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 18:58:25 +0200 Subject: [PATCH 11/29] Repeat CTA after code block --- index.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index 513ba3a..401340a 100644 --- a/index.html +++ b/index.html @@ -164,7 +164,7 @@
-
+
Spock Framework Logo
-

+

Spock

-

+

the enterprise ready specification framework

-

+

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.

@@ -201,7 +201,7 @@

-
From 3e6a61dd79c4d6b3b859a5eef4408c50c519480a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 19:49:35 +0200 Subject: [PATCH 12/29] Update example code and add output --- index.html | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 401340a..40b8fc5 100644 --- a/index.html +++ b/index.html @@ -256,7 +256,7 @@

-
// CalculatorSpec.groovy
+            
// CalculatorSpec.groovy
 import spock.lang.Specification
 
 class CalculatorSpec extends Specification {
@@ -265,11 +265,8 @@ 

given: "A calculator instance" def calculator = new Calculator() - when: "Perform the calculation" - int result = calculator.calculate(a, b, operation) - - then: "The result should match the expected value" - result == expectedResult + expect: "The calculation should match the expected value" // Changed from when/then + calculator.calculate(a, b, operation) == expectedResult where: "Define test data" a | b | operation || expectedResult @@ -281,6 +278,7 @@

1 | -1 | "-" || 2 -2 | -2 | "*" || 4 -4 | -2 | "/" || 2 + 1 | 1 | "+" || 42 // A failing test case } def "Test calculate method with division by zero"() { @@ -338,12 +336,41 @@

throw new IllegalArgumentException("Invalid operation: " + operation) } } + + String toString() { + return "Calc" + } }

Spock's clear given:, when:, then: blocks make understanding test logic intuitive.

-
+
+

Example Test Output:

+
â•·
+└─ 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 ✔
+
+
+
+
Try it online From d8d9e9e56515f7c9813fd8c56aa8b21d993cf85d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonard=20Br=C3=BCnings?= Date: Tue, 15 Apr 2025 20:14:10 +0200 Subject: [PATCH 13/29] More cleanup --- index.html | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index 40b8fc5..eedb28e 100644 --- a/index.html +++ b/index.html @@ -168,8 +168,7 @@ Spock Framework Logo + class="h-64 w-auto mx-auto block logo-img">

@@ -193,7 +192,7 @@

Try it online - + Read the Docs @@ -251,11 +250,12 @@

Built-in Matchers

-