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

Add readme for tests (#554) #555

Merged
merged 23 commits into from
Dec 17, 2019
Merged
Changes from 1 commit
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
56 changes: 56 additions & 0 deletions test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Test

This directory contains tests and testing docs for `Kn client`:
itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved

- [Unit tests](#running-unit-tests) currently reside in the codebase alongside
itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved
the code they test
- [End-to-end tests](#running-end-to-end-tests) :
itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved
- end-to-end tests in [`/test/e2e`](./e2e)

## Running unit tests

To run all unit tests:

```bash
$ hack/build.sh -f -t
itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved
```

_By default `go test` will not run [the e2e tests](#running-end-to-end-tests-locally),
which need [`-tags=e2e`](#running-end-to-end-tests) to be enabled._

## Running end to end tests locally

To run [the e2e tests](./e2e) , you need to have a

1. [running knative environment.](./../DEVELOPMENT.md#create-a-cluster)
2. kn binary in the $path.
itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved

Before running the e2e tests please make sure you dont have any namespaces with the name starting with `kne2etests`
itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved

itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved
```bash
$ ./e2e-tests-local.sh
itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved
```

itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved
### Running a single test case

To run one e2e test case, e.g. TestAutoscaleUpDownUp, use
[the `-run` flag with `go test`](https://golang.org/cmd/go/#hdr-Testing_flags):

```bash
go test -v -tags=e2e -count=1 ./e2e -run ^TestBasicWorkflow$
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do this as suggested test/e2e-tests-local.sh -run ^TestBasicWorkflow$

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@navidshaikh thank you.
Instead of 'go test' use the script ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, see #555 (comment)

```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets swap this with following text:

To run specific e2e test case, e.g. TestBasicWorkflow

test/e2e-tests-local.sh -run ^TestBasicWorkflow$

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing. I have made the changes.


### Running tests in short mode

Running tests in short mode excludes some large-scale E2E tests and saves
time/resources required for running the test suite. To run the tests in short
mode, use
[the `-short` flag with `go test`](https://golang.org/cmd/go/#hdr-Testing_flags)

```bash
go test -v -tags=e2e -count=1 -short ./e2e
itsmurugappan marked this conversation as resolved.
Show resolved Hide resolved
```

### Presubmit tests

Presubmit tests and subsequents tests require a --gcp-project and cannot be run locally.