Skip to content

Commit 6e8844d

Browse files
committed
changes
1 parent 4300fa8 commit 6e8844d

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ jobs:
6565
6666
pact-contract-tests:
6767
runs-on: ubuntu-24.04
68+
timeout-minutes: 10
6869
name: pact-contract-tests
6970
steps:
7071
- name: Checkout code
@@ -81,18 +82,6 @@ jobs:
8182
- name: Start Pact Broker infrastructure
8283
run: docker compose --file spring-boot-example/docker-pact-broker-compose.yml up -d
8384

84-
- name: Wait for Pact Broker to be ready
85-
run: |
86-
echo "Waiting for Pact Broker to be ready..."
87-
for i in {1..30}; do
88-
if curl -f http://localhost:9292 > /dev/null 2>&1; then
89-
echo "Pact Broker is ready!"
90-
break
91-
fi
92-
echo "Waiting for Pact Broker... ($i/30)"
93-
sleep 2
94-
done
95-
9685
- name: Run consumer contract tests
9786
working-directory: spring-boot-example
9887
run: ./mvnw -B test -Dtest=StockApiContractTest
@@ -103,10 +92,9 @@ jobs:
10392

10493
- name: Run provider verification tests
10594
working-directory: spring-boot-example
106-
run: ./mvnw -B test -Dtest=StockApiProviderTest
95+
run: ./mvnw -B test -Dtest=StockApiProviderTest -DdisablePactVerification=false
10796

10897
- name: Clean up Docker containers
10998
if: always()
11099
run: |
111100
docker compose --file spring-boot-example/docker-pact-broker-compose.yml down -v
112-
docker compose --file spring-boot-example/docker-compose.yml down -v

CLAUDE.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ docker-compose up -d
4848

4949
# Generate JGiven reports
5050
./mvnw jgiven:report
51+
52+
# Run Pact consumer tests
53+
./mvnw test -Dtest=StockApiContractTest
54+
55+
# Publish pacts to broker (requires running Pact Broker)
56+
docker-compose -f docker-pact-broker-compose.yml up -d
57+
./mvnw pact:publish
58+
59+
# Run Pact provider verification tests (by default skipped with system property)
60+
./mvnw test -Dtest=StockApiProviderTest
5161
```
5262

5363
### Jakarta EE Example

spring-boot-example/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
<jmh-core.version>1.37</jmh-core.version>
4747
<pitest.version>1.18.0</pitest.version>
4848
<pact.version>4.6.17</pact.version>
49+
<disablePactVerification>true</disablePactVerification>
4950
</properties>
5051

5152
<dependencyManagement>

spring-boot-example/src/test/java/de/rieckpil/blog/pact/StockApiProviderTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
import de.rieckpil.blog.Application;
1111
import org.apache.hc.core5.http.HttpRequest;
1212
import org.junit.jupiter.api.BeforeEach;
13-
import org.junit.jupiter.api.Disabled;
1413
import org.junit.jupiter.api.TestTemplate;
14+
import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
1515
import org.junit.jupiter.api.extension.ExtendWith;
1616
import org.springframework.boot.test.context.SpringBootTest;
1717
import org.springframework.boot.test.web.server.LocalServerPort;
1818

1919
import static org.springframework.boot.test.context.SpringBootTest.WebEnvironment.RANDOM_PORT;
2020

21-
@Disabled("Requires running Pact Broker, see Docker Compose")
2221
@Provider("stock-api")
22+
@DisabledIfSystemProperty(named = "disablePactVerification", matches = "true", disabledReason = "Requires running Pact Broker, see Docker Compose")
2323
@PactBroker(url = "http://localhost:9292/", authentication = @PactBrokerAuth(username = "pact-sample", password = "pact-sample"))
2424
@SpringBootTest(webEnvironment = RANDOM_PORT, classes = Application.class)
2525
public class StockApiProviderTest {

0 commit comments

Comments
 (0)