Sample project written in .net
To be able to setup this example you will need
- shell console - preferred WSL2 and Ubuntu release
- .net 5.0 - current release on date of writing it is: 5.0.0-rc.2
Please not to execute all scripts from containing directory.
It's enough for you to run ./scripts/runAcceptanceTests.sh
to
- Build a docker image with Artifactory (normally you would have that running / you could also use Git instead)
- We run the app on port
5000
in theContractTests
mode - We run the Spring Cloud Contract docker image that has the
contracts
folder mounted with contracts - From the mounted folder tests are generated against the running application
- Once the tests have passed stubs are generated and uploaded to Artifactory
It's enough for you to run ./scripts/runStubs.sh
to
- get stubs from Artifactory and run them on specified port with Wiremock
- once the stub runner is running you can test your api against defined contract tests
To learn more about stub runner go to:
https://cloud.spring.io/spring-cloud-contract/reference/html/docker-project.html#docker-stubrunner
- Installed .NET SDK 5.0
From command line execute dotnet build
From command line execute dotnet run
docker build -f src/AspNetCoreExample/Dockerfile -t cdc-aspnetcoreexample .
docker run -d -p 5000:80 cdc-aspnetcoreexample
docker run -d -e "ASPNETCORE_ENVIRONMENT=ContractTests" -p 5000:80 cdc-aspnetcoreexample
http://localhost:5000/swagger - swagger ui http://localhost:5000/api-docs - redoc
Section describes commands that will be used by Cloud Foundry pipelines.
Warning: Output from below commands start with extra spaces in each line. Please make left trim
(you can do it by piping to xargs
)
e.g.
dotnet msbuild /nologo /t:cfpappname | xargs
dotnet msbuild /nologo /t:cfpversion | xargs
dotnet msbuild /nologo /t:cfpgroupid | xargs
dotnet msbuild /nologo /t:cfpartifactid | xargs
dotnet msbuild /nologo /t:CFPUnitTests | xargs
dotnet msbuild /nologo /t:CFPE2eTests | xargs
dotnet msbuild /nologo /t:CFPSmokeTests | xargs
dotnet msbuild /nologo /t:CFPPublish /p:Configuration=Release