Skip to content
This repository has been archived by the owner on Apr 9, 2022. It is now read-only.

Commit

Permalink
Added coveralls support.
Browse files Browse the repository at this point in the history
  • Loading branch information
Castyr committed Mar 15, 2019
1 parent 2408fa5 commit b0decf0
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 16 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ jdk:
- oraclejdk8
sudo: required
script:
- ./gradlew test
- ./gradlew test
after_success:
- ./gradlew cobertura coveralls
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,26 @@ sh u-integration-test.sh
```

## Running Contract Tests
Start the domain services with internal mocks so that only the endpoints will be tested.
```bash
sh u-contract-test.sh
docker-compose -f docker-compose-internal-mocked.yml start
```
Start the PactBroker service and check `http://localhost:8089` that it is live.
```bash
docker-compose -f ./pact-broker/docker-compose.yml start
```
Generate the PACTs and execute them.
```bash
sh ./scripts/generate-publish-pact-tests.sh
sh ./scripts/run-pact-tests.sh
```
Stop the PactBroker.
```bash
docker-compose -f ./pact-broker/docker-compose.yml down
```
Stop the services with internal mocks.
```bash
docker-compose -f docker-compose-internal-mocked.yml down
```

## Running Service Readiness Tests
Expand Down
33 changes: 23 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ subprojects { project ->
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'groovy'
apply plugin: 'net.saliman.cobertura'
apply plugin: 'com.github.kt3k.coveralls'

cobertura.coverageFormats = ['html', 'xml']

if(project.name != 'api') {
apply plugin: "application"
Expand Down Expand Up @@ -129,6 +133,19 @@ subprojects { project ->
}
}
if(project.name != 'api') {

task clearPactBroker() {
doLast() {
def services = ['Customers', 'AccountCmd', 'AccountQuery', 'Transactions']
for (service in services) {
println "http://localhost:8089/pacticipants/" + service
def p = ['curl', '-X', 'DELETE', "http://localhost:8089/pacticipants/" + service].
execute()
println p.text
}
}
}

pact {
serviceProviders {
// You can define as many as you need, but each must have a unique name
Expand Down Expand Up @@ -178,7 +195,12 @@ subprojects { project ->
}

publish {
pactDirectory = '../pact-tests' // defaults to $buildDir/pacts
def folder = new File('./pact-tests')
if (folder.exists()) {
pactDirectory = './pact-tests'
} else {
pactDirectory = '../pact-tests'
}
pactBrokerUrl = 'http://localhost:8089'
}
}
Expand All @@ -191,12 +213,3 @@ subprojects { project ->

test.finalizedBy(jacocoTestCoverageVerification)
}

task clearPactBroker() {
def services = ['Customers', 'AccountCmd', 'AccountQuery', 'Transactions']
for(service in services) {
println "http://localhost:8089/pacticipants/" + service
def p = ['curl', '-X', 'DELETE', "http://localhost:8089/pacticipants/" + service].execute()
println p.text
}
}
File renamed without changes.
15 changes: 15 additions & 0 deletions scripts/generate-publish-pact-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'#!/bin/sh'

# Generate the Pact JSON files in the root of the project in 'pact-tests'.
# To change the target directory see `systemProperties['pact.rootDir'] = "../pact-tests"`
# An example change could be `systemProperties['pact.rootDir'] = "${buildDir}/pact-tests"` to
# store them in each projects directory, but then the publish location needs to be created for each
# provider.
./gradlew :account-cmd:test --tests "*.contract.consumer.*"
./gradlew :account-query:test --tests "*.contract.consumer.*"
./gradlew :customers:test --tests "*.contract.consumer.*"
./gradlew :transactions:test --tests "*.contract.consumer.*"

# Since the PACT plugin is global to all projects this will publish all provider pacts, not just
# transactions.
./gradlew :transactions:pactPublish
4 changes: 0 additions & 4 deletions scripts/pact-tests.sh

This file was deleted.

5 changes: 5 additions & 0 deletions scripts/run-pact-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'#!/bin/sh'
./gradlew :customers:pactVerify_AccountCmd
./gradlew :customers:pactVerify_AccountQuery
./gradlew :customers:pactVerify_Customers
./gradlew :customers:pactVerify_Transactions

0 comments on commit b0decf0

Please sign in to comment.