Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document -skip flag in go test #204

Merged
merged 5 commits into from
Feb 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion examples/skip_flags/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,55 @@ To skip a particular labeled feature , do the following

```shell
./skipflags.test --skip-labels "env=prod"
```
```

### Skip tests using built in -skip flag in go test

Go 1.20 introduces the `-skip` flag for `go test` command to skip tests.


Tests can also be skipped based on test function name, feature name and assesment name with `-skip` flag

```shell
go test -v . -skip <test_function_name>/<feature_name>/<assesment_name>
```

To skip a test by test function name `TestSkipFlags`, do the following

```shell
reetasingh marked this conversation as resolved.
Show resolved Hide resolved
go test -v . -skip TestSkipFlags
```


To skip a feature with name `pod list` within test function `TestSkipFlags`, do the following

```shell
go test -v . -skip TestSkipFlags/pod list
```


To skip a assesment with name `pods from kube-system` within feature `pod list` within test function `TestSkipFlags`, do the following

```shell
reetasingh marked this conversation as resolved.
Show resolved Hide resolved
go test -v . -skip TestSkipFlags/pod list/pods from kube-system
```

It is not possible to skip features by label name with this option
reetasingh marked this conversation as resolved.
Show resolved Hide resolved


### Skip tests using both -skip flag and --skip-xxx flags

We can also use the combination of `-skip` flag built in `go test` and `-skip-xxx` flags provided by the e2e-framework to skip multiple tests


To skip a feature `pod list` within test function `TestSkipFlags` and feature `appsv1/deployment` within test function `TestSkipFlags`, do the following

```shell
go test -v . -skip TestSkipFlags/appsv1/deployment -args --skip-features "pod list"
```

To skip a particular labeled feature with label `env=prod` and assesment `deployment creation` within feature `appsv1/deployment` within test function `TestSkipFlags`, do the following

```shell
go test -v . -skip TestSkipFlags/appsv1/deployment/deployment_creation -args --skip-labels "env=prod"
```