由於之後我打算將godog在CI/CD工具上定期跑BDD測試,所以我想要將godog封裝在image內,以下是我自己寫的dockerfile,提供各位參考。
/usr/local/bin
資料夾內FROM golang:1.16.8
RUN wget https://github.com/cucumber/godog/releases/download/v0.11.0/godog-v0.11.0-linux-amd64.tar.gz
RUN tar -zxvf godog-v0.11.0-linux-amd64.tar.gz && mv godog-v0.11.0-linux-amd64/godog /usr/local/bin/godog && rm godog-v0.11.0-linux-amd64.tar.gz
docker build --no-cache --pull --force-rm -t rain123473/godog:v0.11.0 -f godog.dockerfile .
本機用剛剛build的image測試godog
docker run --rm -v $(pwd):/app -w /app rain123473/godog:v0.11.0 sh -c "godog"
Feature: write ithome30days
As a happy contestant
Scenario: Write 5 out of 30 # features/godogs.feature:4
Given there are 30 days # godogs_test.go:21 -> thereAreDays
When I write 5 # godogs_test.go:10 -> iWrite
Then there should be 25 remaining # godogs_test.go:25 -> thereShouldBeRemaining
1 scenarios (1 passed)
3 steps (3 passed)
528.7µs
docker run
就可以進行測試了這樣子是不是很方便呢~?明天就來帶著大家把godog搭配CI/CD的組合技組起來