gotesplit splits the testng in Go into a subset and run it
% gotesplit [options] [pkgs...] [-- go-test-arguments...]
-total uint
total number of test splits (CIRCLE_NODE_TOTAL is used if set) (default 1)
-index uint
zero-based index number of test splits (CIRCLE_NODE_INDEX is used if set) (default 0)
-junit-dir
directory to store test result as a JUnit format (optional)
% gotesplit -total=10 -index=0 -- -v -short
go test -v -short -run ^(?:TestAA|TestBB)$
The gotesplit splits the testng in Go into a subset and run it.
It is very useful when you want to run tests in parallel in a CI environment.
# Install the latest version. (Install it into ./bin/ by default).
% curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
# Specify installation directory ($(go env GOPATH)/bin/) and version.
% curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s -- -b $(go env GOPATH)/bin [vX.Y.Z]
# In alpine linux (as it does not come with curl by default)
% wget -O - -q https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s [vX.Y.Z]
# go get
% go get github.com/Songmu/gotesplit/cmd/gotesplit
We don't need to specify the -total and -index flag on CircleCI because gotesplit reads the CIRCLE_NODE_TOTAL
and CIRCLE_NODE_INDEX
environment variables automatically.
parallelism: 5
docker:
- image: circleci/golang:1.15.3
steps:
- checkout
- run:
command: |
curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
bin/gotesplit ./... -- -v
name: CI
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
parallelism: [3]
index: [0,1,2]
steps:
- uses: actions/setup-go@v2
- uses: actions/checkout@v2
- name: Run tests parallelly
run: |
curl -sfL https://raw.githubusercontent.com/Songmu/gotesplit/main/install.sh | sh -s
bin/gotesplit -total ${{ matrix.parallelism }} -index ${{ matrix.index }} ./... -- -v