https://github.com/gregoryv/xtest
Show different ways of creating test suites in Go
https://github.com/gregoryv/xtest
Last synced: about 1 year ago
JSON representation
Show different ways of creating test suites in Go
- Host: GitHub
- URL: https://github.com/gregoryv/xtest
- Owner: gregoryv
- License: mit
- Created: 2023-04-05T10:20:28.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-14T15:37:23.000Z (over 1 year ago)
- Last Synced: 2025-02-05T07:19:19.323Z (over 1 year ago)
- Language: Go
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: license.txt
Awesome Lists containing this project
README
xtest - show how to create test suites in Go
This example shows how to group tests.
Use build tags or by supplying a suite name.
The latter has the benefit of always compiling your tests.
## Quick start
$ git clone git@github.com:gregoryv/xtest.git
$ cd xtest
In this demo there are three tests spread out over two files
1. a_test.go TestAlways and TestA
2. b_test.go TestB
TestAlways is not part of any test suite nor is the file a_test.go tagged in any way
TestA however has is skipped unless you provide a the blue test suite using --test-suit=blue
TestB is in a file tagged with `//go:build systest`
$ go test -v
=== RUN TestAlways
--- PASS: TestAlways (0.00s)
=== RUN TestA
a_test.go:10: include with --test-suite=[blue]
--- SKIP: TestA (0.00s)
PASS
ok github.com/gregoryv/xtest 0.001s
You can see that TestA is skipped, but included in the compiled set of
tests, TestB however is not compiled at all.
$ go test --tags=systest -v
=== RUN TestAlways
--- PASS: TestAlways (0.00s)
=== RUN TestA
a_test.go:10: include with --test-suite=[blue]
--- SKIP: TestA (0.00s)
=== RUN TestB
--- FAIL: TestB (0.00s)
FAIL
exit status 1
FAIL github.com/gregoryv/xtest 0.001s
Using --tags=systest TestB is compiled And executed where as TestA is
still just compiled but not included.
$ go test --tags=systest --test-suite=red,blue,green -v
=== RUN TestAlways
--- PASS: TestAlways (0.00s)
=== RUN TestA
--- PASS: TestA (0.00s)
=== RUN TestB
--- FAIL: TestB (0.00s)
FAIL
exit status 1
FAIL github.com/gregoryv/xtest 0.001s