Skip to content

Commit c62b030

Browse files
Senjuti256tekton-robot
authored andcommitted
Refactored README.md file.
1 parent 2c3e315 commit c62b030

File tree

1 file changed

+42
-27
lines changed

1 file changed

+42
-27
lines changed

test/README.md

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,58 @@
11
# Tests
22

3-
To run tests:
3+
## Unit tests
4+
5+
Unit tests live side by side with the code they are testing and can be run with:
46

57
```shell
6-
# Unit tests
78
go test $(go list ./... | grep -v third_party/)
89
# or
910
make test-unit
10-
11-
# Integration tests (against your current kube cluster)
12-
go test -v -count=1 -tags=e2e ./test/...
1311
```
1412

15-
## Unit tests
13+
## End to end tests
1614

17-
Unit tests live side by side with the code they are testing and can be run with:
15+
### Some prerequisites to run tests:
16+
17+
1. Spin up a kind/minikube cluster.
18+
19+
2. To run end to end tests, you will need to have a running Tekton pipeline deployed on your cluster, see [Install Pipeline](../DEVELOPMENT.md#install-pipeline).
20+
21+
3. Next install Tekton Triggers in the cluster, see [Install Triggers](https://github.com/tektoncd/triggers/blob/main/docs/install.md#installation)
22+
23+
Set environment variable `TEST_CLUSTERTASK_LIST_EMPTY` to any value if tests are run in an environment which contains `clustertasks`.
1824

1925
```shell
20-
go test $(go list ./... | grep -v third_party/)
21-
# or
22-
make test-unit
26+
export TEST_CLUSTERTASK_LIST_EMPTY=empty
2327
```
2428

25-
By default `go test` will not run [the end to end tests](#end-to-end-tests),
26-
which need `-tags=e2e` to be enabled.
29+
Set `SYSTEM_NAMESPACE` variable to appropriate value (say tekton-pipelines) based on the namespace where Tekton Pipelines system components reside within the Kubernetes cluster.
2730

28-
## End to end tests
31+
```shell
32+
export SYSTEM_NAMESPACE=<namespace-name> (eg: export SYSTEM_NAMESPACE=tekton-pipelines)
33+
```
34+
35+
### Running
36+
37+
End to end tests live in [this](../test/e2e/) directory. By default `go test` will not run [the end to end tests](#end-to-end-tests),
38+
it need `-tags=e2e` to be enabled in order to run these tests, hence you must provide `go` with `-tags=e2e`.
2939

30-
### prerequisite
3140
```shell
3241
go build -o tkn github.com/tektoncd/cli/cmd/tkn
3342
export TEST_CLIENT_BINARY=<path-to-tkn-binary-directory>/tkn ( eg: export TEST_CLIENT_BINARY=$PWD/tkn )
3443
```
35-
Set environment variable `TEST_CLUSTERTASK_LIST_EMPTY` to any value if tests are run in an environment which contains `clustertasks`
36-
### Running
37-
38-
To run end to end tests, you will need to have a running Tekton
39-
pipeline deployed on your cluster, see [Install Pipeline](../DEVELOPMENT.md#install-pipeline).
40-
41-
End to end tests live in this directory. To run these tests, you must provide
42-
`go` with `-tags=e2e`. By default the tests run against your current kubeconfig
43-
context, but you can change that and other settings with [the flags](#flags):
44+
By default the tests run against your current kubeconfig context:
4445

4546
```shell
4647
go test -v -count=1 -tags=e2e -timeout=20m ./test/e2e/...
48+
```
49+
You can change the kubeconfig context and other settings with [the flags](#flags).
50+
51+
```shell
4752
go test -v -count=1 -tags=e2e -timeout=20m ./test/e2e/... --kubeconfig ~/special/kubeconfig --cluster myspecialcluster
4853
```
4954

50-
You can also use
51-
[all of flags defined in `knative/pkg/test`](https://github.com/knative/pkg/tree/master/test#flags).
55+
You can also use [all of flags defined in `knative/pkg/test`](https://github.com/knative/pkg/tree/master/test#flags).
5256

5357
### Flags
5458

@@ -74,10 +78,21 @@ go test -v -count=1 ./test/e2e/... --kubeconfig ~/special/kubeconfig --cluster m
7478

7579
### One test case
7680

77-
To run one e2e test case, e.g. TestTaskRun, use
81+
To run one e2e test case, e.g. TestPipelinesE2E test, use
7882
the `-run` flag with `go test`
7983

8084
```bash
81-
go test -v -count=1 ./test/e2e/... -run ^TestPipelinesE2E$
85+
go test -v ./test/... -tags=e2e -run ^TestPipelinesE2E
8286
```
8387

88+
### Prerequisite to run make check and make generated
89+
90+
Ensure that golangci-lint and yamllint are installed on your development machine. If not then install them following [golangci-lint](https://golangci-lint.run/usage/install/) and [yamllint](https://yamllint.readthedocs.io/en/stable/quickstart.html).
91+
92+
Next step will be to run
93+
```bash
94+
# For linting the golang and YAML files
95+
make check
96+
# To check diff in goldenfile and [docs](https://github.com/tektoncd/cli/tree/main/docs), update and autogenerate them
97+
make generated
98+
```

0 commit comments

Comments
 (0)