diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-15 20:24:19 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-01-17 19:14:59 +1100 |
commit | 2691477aff8505275488e35af7611fb78b53b328 (patch) | |
tree | fae3722004872d57ee652e54656c8f0f01bb3e96 /docs | |
parent | 8ca71eeb362aebbb8b148f0ef2fc58d33fc05ee0 (diff) |
allow sandbox mode with integration tests
Diffstat (limited to 'docs')
-rw-r--r-- | docs/Integration_Tests.md | 45 |
1 files changed, 37 insertions, 8 deletions
diff --git a/docs/Integration_Tests.md b/docs/Integration_Tests.md index 814e593ca..1bb797b3a 100644 --- a/docs/Integration_Tests.md +++ b/docs/Integration_Tests.md @@ -33,17 +33,32 @@ git commit -am "myfile1" ## Running tests +### From a TUI + +You can run/record/sandbox tests via a TUI with the following command: + +``` +go run test/lazyintegration/main.go +``` + +This TUI makes much of the following documentation redundant, but feel free to read through anyway! + +### From command line + To run all tests - assuming you're at the project root: + ``` go test ./pkg/gui/ ``` To run them in parallel + ``` PARALLEL=true go test ./pkg/gui ``` To run a single test + ``` go test ./pkg/gui -run /<test name> # For example, to run the `tags` test: @@ -51,29 +66,35 @@ go test ./pkg/gui -run /tags ``` To run a test at a certain speed + ``` SPEED=2 go test ./pkg/gui -run /<test name> ``` To update a snapshot + ``` -UPDATE_SNAPSHOTS=true go test ./pkg/gui -run /<test name> +MODE=updateSnapshot go test ./pkg/gui -run /<test name> ``` ## Creating a new test To create a new test: -1) Copy and paste an existing test directory and rename the new directory to whatever you want the test name to be. Update the test.json file's description to describe your test. -2) Update the `setup.sh` any way you like -3) If you want to have a config folder for just that test, create a `config` directory to contain a `config.yml` and optionally a `state.yml` file. Otherwise, the `test/default_test_config` directory will be used. -4) From the lazygit root directory, run: + +1. Copy and paste an existing test directory and rename the new directory to whatever you want the test name to be. Update the test.json file's description to describe your test. +2. Update the `setup.sh` any way you like +3. If you want to have a config folder for just that test, create a `config` directory to contain a `config.yml` and optionally a `state.yml` file. Otherwise, the `test/default_test_config` directory will be used. +4. From the lazygit root directory, run: + ``` -RECORD_EVENTS=true go test ./pkg/gui -run /<test name> +MODE=record go test ./pkg/gui -run /<test name> ``` -5) Feel free to re-attempt recording as many times as you like. In the absence of a proper testing framework, the more deliberate your keypresses, the better! -6) Once satisfied with the recording, stage all the newly created files: `test.json`, `setup.sh`, `recording.json` and the `expected` directory that contains a copy of the repo you created. + +5. Feel free to re-attempt recording as many times as you like. In the absence of a proper testing framework, the more deliberate your keypresses, the better! +6. Once satisfied with the recording, stage all the newly created files: `test.json`, `setup.sh`, `recording.json` and the `expected` directory that contains a copy of the repo you created. The resulting directory will look like: + ``` actual/ (the resulting repo after running the test, ignored by git) expected/ (the 'snapshot' repo) @@ -85,6 +106,14 @@ recording.json Feel free to create a hierarchy of directories in the `test/integration` directory to group tests by feature. +## Sandboxing + +The integration tests serve a secondary purpose of providing a setup for easy sandboxing. If you want to run a test in sandbox mode (meaning the session won't be recorded and we won't create/update snapshots), go: + +``` +MODE=sandbox go test ./pkg/gui -run /<test name> +``` + ## Feedback If you think this process can be improved, let me know! It shouldn't be too hard to change things. |