mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Format Test Results As A JSON File as an RSpec TIL
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
||||
|
||||
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
|
||||
|
||||
_1338 TILs and counting..._
|
||||
_1339 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1020,6 +1020,7 @@ _1338 TILs and counting..._
|
||||
|
||||
- [Check Specific Arguments To Received Method](rspec/check-specific-arguments-to-received-method.md)
|
||||
- [Find Minimal Set Of Tests Causing A Flicker](rspec/find-minimal-set-of-tests-causing-a-flicker.md)
|
||||
- [Format Test Results As A JSON File](rspec/format-test-results-as-a-json-file.md)
|
||||
- [Run Tests With Documentation Formatting](rspec/run-tests-with-documentation-formatting.md)
|
||||
- [Use Specific Cache Store In A Single Test](rspec/use-specific-cache-store-in-a-single-test.md)
|
||||
|
||||
|
||||
21
rspec/format-test-results-as-a-json-file.md
Normal file
21
rspec/format-test-results-as-a-json-file.md
Normal file
@@ -0,0 +1,21 @@
|
||||
# Format Test Results As A JSON File
|
||||
|
||||
The most common output format for RSpec test results is _progress_ which shows
|
||||
the dot (`.`) or `F` for each test pass and fail. RSpec supports other formats,
|
||||
including JSON.
|
||||
|
||||
You'd typically want to use the JSON format when you want to programmatically
|
||||
work with the results. And the results would be most accessible if they ended
|
||||
up in a file.
|
||||
|
||||
So, when formatting the results to JSON, we typically also want to specify an
|
||||
output file. We'll need to use two flags — `--format` and `--out`.
|
||||
|
||||
```bash
|
||||
$ rspec --format json --out test_run_1.json
|
||||
```
|
||||
|
||||
When this test run completes, we will have the results in JSON format in the
|
||||
newly created `test_run_1.json` file in the current directory.
|
||||
|
||||
See `rspec --help` for more details.
|
||||
Reference in New Issue
Block a user