[go: up one dir, main page]

Skip to content

Commit

Permalink
update readme to make it easier to run test locally (nytimes#22)
Browse files Browse the repository at this point in the history
* update readme to make it easier to run test locally

* update to address review comments
  • Loading branch information
shawn620 authored Feb 17, 2021
1 parent fb7c236 commit 9c6928b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ A simple concurrent HTTP testing tool

### Write a simple test

Create a file `tests.yaml` with the following content:
Create a file `tests.yml` with the following content:

```yaml
```yml
tests:
- description: 'root' # Description, will be printed with test results
request: # Request to send
Expand All @@ -21,17 +21,17 @@ tests:
### Run tests locally
This program is distributed as a Docker image. To run a container locally:
This program is distributed as a Docker image. To run a container locally (under a folder contains tests related yml file):
```bash
docker run --rm \
-v $(pwd)/tests.yaml:/tests/tests.yaml \
-v $(pwd)/httpbin.yml:/tests/tests.yml \
-e "TEST_HOST=example.com" \
nytimes/httptest
```

You should see an output similar to this:
```
passed: tests.yaml | root | /
passed: tests.yml | root | /
1 passed
0 failed
Expand All @@ -42,13 +42,13 @@ Tip: If your test cases have conditions on environment variables (see `condition

```
docker run --rm \
-v $(pwd)/tests.yaml:/tests/tests.yaml \
-e "TEST_HOST=stg.example.com" \
-v $(pwd)/route-abc-tests.yml:/tests/tests.yml \
-e "TEST_HOST=www.stg.example.com" \
-e "TEST_ENV=stg" \
nytimes/httptest
```

By default, the program parses all files in `$(pwd)/tests` recursively.
By default, if your current working directory is `$(pwd)/tests`, the program will parse all files in `$(pwd)/tests` recursively.
This can be changed using an environment variable.

### Run tests in a CI/CD pipeline
Expand All @@ -59,7 +59,7 @@ Examples

- Drone

```yaml
```yml
pipeline:
tests:
image: nytimes/httptest
Expand All @@ -84,7 +84,7 @@ Examples
A few global configurations (applied to all tests) can be specified by
environment variables:

- `TEST_DIRECTORY`: Local directory that contains the test definition YAML
- `TEST_DIRECTORY`: Local directory that contains the test definition YML or YAML
files. Default: `tests`

- `TEST_HOST`: Host to test. Can be overridden by `request.host` of individual
Expand All @@ -95,21 +95,21 @@ environment variables:
Default: `2`.

- `TEST_DNS_OVERRIDE`: Override the IP address for `TEST_HOST`. Does not work
for `request.host` specified in YAML.
for `request.host` specified in YML.

- `TEST_PRINT_FAILED_ONLY`: Only print failed tests. Valid values: `false` or
`true`. Default: `false`.

### Environment variable substitution

This program supports variable substitution from environment variables in YAML
This program supports variable substitution from environment variables in YML
files. This is useful for handling secrets or dynamic values.
Visit [here](https://github.com/drone/envsubst) for
supported functions.

Example:

```yaml
```yml
tests:
- description: 'get current user'
request:
Expand Down Expand Up @@ -250,7 +250,7 @@ Required fields for each test:

All other fields are optional. All matchings are case insensitive.

```yaml
```yml
tests:
- description: 'root' # Description, will be printed with test results. Required
conditions: # Specify conditions. Test only runs when all conditions are met
Expand Down

0 comments on commit 9c6928b

Please sign in to comment.