Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rwxrob/tinout
Easy Input-Output Test Specifications in YAML
https://github.com/rwxrob/tinout
golang parsers specifications tdd testing tools yaml
Last synced: 3 months ago
JSON representation
Easy Input-Output Test Specifications in YAML
- Host: GitHub
- URL: https://github.com/rwxrob/tinout
- Owner: rwxrob
- License: agpl-3.0
- Created: 2019-12-28T23:26:16.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-12-04T03:08:09.000Z (about 2 years ago)
- Last Synced: 2024-10-11T01:38:27.722Z (3 months ago)
- Topics: golang, parsers, specifications, tdd, testing, tools, yaml
- Language: Go
- Homepage:
- Size: 43 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Easy Input-Output Test Specifications in YAML
[![GoDoc](https://godoc.org/github.com/rwxrob/tinout?status.svg)](https://godoc.org/github.com/rwxrob/tinout)
[![Go Report
Card](https://goreportcard.com/badge/github.com/rwxrob/tinout)](https://goreportcard.com/report/github.com/rwxrob/tinout)
[![Coverage](https://gocover.io/_badge/github.com/rwxrob/tinout)](https://gocover.io/github.com/rwxrob/tinout)Often testing requires a large number of inputs with specific outputs --- particularly when testing parsers and grammar implementations. Such tests are also usually required across different language implementations with different testing suites and approaches. For testing such specifications it makes sense to maintain inputs and outputs in a language-agnostic way. This is one such approach.
YAML is used as the format for the test file because of its strong support for multi-line data. Specifications --- which are maintained by human hands --- are a particularly good use case for YAML structured data.
Any number or fields may be included, but all key names must begin with an initial capital letter. The following are common and expected:
* `Name` - name or title of the spec
* `Version` - semantic version of the spec being tested
* `Source` - URL of YAML files that define the spec
* `Issues` - URL to report issues with the spec
* `Discuss` - URL of place to discuss the spec
* `Notes` - any notes about the specification
* `Date` - date of the specification
* `License` - license of the specOne of the following is required although both are allowed:
* `Tests` - array of tests
* `Sections` - array of sections containing testsIf both are included the non-grouped tests will be checked first.
The content of `Tests` can be a simple array of tests, or an array of
test groups. All tests must have an `I` and `O` property and can
optionally add an `N` property as well:Must:
* `I`: Any string, number, or boolean containing the input.
* `O`: Any string, number, or boolean containing the required output.Optional:
* `N`: Short note about what is being tests, often from the specification.
Here's an example from the CommonMark specification. The first uses the array format:
```yaml
Name: CommonMark
Version: v1.0.0
Source: https://gitlab.com/commonmark/commonmark-spec
Issues: https://gitlab.com/commonmark/commonmark-spec/issues
Discuss: https://talk.commonmark.org/
Notes: CommonMark is a clarification version of Markdown.
Tests:
- I: '\tfoo\tbaz\t\tbim\n'
O: '\n'foo\tbaz\t\tbim\n
N: 'tabs are equal to four spaces'
- I: ' \tfoo\tbaz\t\tbim\n'
O: '\n'foo\tbaz\t\tbim\n
```And the same as a map with keys matching the sections:
```yaml
Sections:
- Name: Tabs
Notes: Tests related to use of the tab character.
Tests:
- I: '\tfoo\tbaz\t\tbim\n'
O: '\n'foo\tbaz\t\tbim\n
N: 'tabs are equal to four spaces'
- I: ' \tfoo\tbaz\t\tbim\n'
O: '\n'foo\tbaz\t\tbim\n
```See [tests](tinout_test.go) for usage examples.
## Go (golang) Reference Implementation
A reference implementation in Go has been included for reference and
import inclusion:```go
package mytestimport (
"testing""github.com/rwxrob/tinout"
)// ...
```