Skip to content

Commit 6c18ec5

Browse files
committed
docs: Add documentation for creating and using yamlfmt's integration tests.
1 parent a70006e commit 6c18ec5

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

docs/integration-test.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Integration Testing
2+
3+
yamlfmt has integration testing that tests invocations end-to-end.
4+
5+
## Run
6+
7+
Integration tests are excluded from `go test` by default using build tags. To build and execute the integration test, use:
8+
9+
```shell
10+
make integrationtest
11+
```
12+
13+
## Update
14+
15+
The "golden" / expected output files can be (re-)generated by the test framework. To do so, run:
16+
17+
```shell
18+
make integrationtest_update
19+
```
20+
21+
## Add new test case
22+
23+
* Run the following command to create the directory structure for the new test:
24+
25+
```shell
26+
TESTNAME=my_new_test make command_test_case
27+
```
28+
* Add example input files to `testdata/${TESTNAME}/before`.
29+
* Add the expected output to `testdata/${TESTNAME}/stdout/stdout.txt` if applicable.
30+
* `make command_test_case` added a new Go test to `integrationtest/command/command_test.go`. Update the `yamlfmt` flags so the invokation uses the feature the test should cover.
31+
* Run the following command to generate the expected "golden" output of the test:
32+
33+
```shell
34+
make integrationtest_update
35+
```
36+
* Review the generated output to ensure it is expected.

0 commit comments

Comments
 (0)