You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unit tests live side by side with the code they are testing and can be run with:
4
6
5
7
```shell
6
-
# Unit tests
7
8
go test$(go list ./... | grep -v third_party/)
8
9
# or
9
10
make test-unit
10
-
11
-
# Integration tests (against your current kube cluster)
12
-
go test -v -count=1 -tags=e2e ./test/...
13
11
```
14
12
15
-
## Unit tests
13
+
## End to end tests
16
14
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`.
18
24
19
25
```shell
20
-
go test$(go list ./... | grep -v third_party/)
21
-
# or
22
-
make test-unit
26
+
export TEST_CLUSTERTASK_LIST_EMPTY=empty
23
27
```
24
28
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.
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:
44
45
45
46
```shell
46
47
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
47
52
go test -v -count=1 -tags=e2e -timeout=20m ./test/e2e/... --kubeconfig ~/special/kubeconfig --cluster myspecialcluster
48
53
```
49
54
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).
52
56
53
57
### Flags
54
58
@@ -74,10 +78,21 @@ go test -v -count=1 ./test/e2e/... --kubeconfig ~/special/kubeconfig --cluster m
74
78
75
79
### One test case
76
80
77
-
To run one e2e test case, e.g. TestTaskRun, use
81
+
To run one e2e test case, e.g. TestPipelinesE2E test, use
78
82
the `-run` flag with `go test`
79
83
80
84
```bash
81
-
go test -v -count=1 ./test/e2e/... -run ^TestPipelinesE2E$
85
+
go test -v ./test/... -tags=e2e -run ^TestPipelinesE2E
82
86
```
83
87
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
0 commit comments