Skip to content

Commit 8db884c

Browse files
authored
java: Implement Cucumber JSON formatter (#1)
1 parent 6a8e0a1 commit 8db884c

File tree

408 files changed

+12999
-3
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

408 files changed

+12999
-3
lines changed

.github/renovate.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
3+
"extends": [
4+
"github>cucumber/renovate-config"
5+
],
6+
"ignorePaths": [
7+
"testdata/cucumber-jvm/**",
8+
"testdata/cucumber-js/**",
9+
"testdata/cucumber-ruby/**"
10+
]
11+
}

.github/workflows/release-github.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Release GitHub
2+
3+
on:
4+
push:
5+
branches: [release/*]
6+
7+
jobs:
8+
create-github-release:
9+
name: Create GitHub Release and Git tag
10+
runs-on: ubuntu-latest
11+
environment: Release
12+
permissions:
13+
contents: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: cucumber/[email protected]
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release-mvn.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release Maven
2+
3+
on:
4+
push:
5+
branches: [release/*]
6+
7+
jobs:
8+
publish-mvn:
9+
name: Publish Maven Package
10+
runs-on: ubuntu-latest
11+
environment: Release
12+
steps:
13+
- uses: actions/checkout@v4
14+
- uses: actions/setup-java@v4
15+
with:
16+
distribution: 'temurin'
17+
java-version: '11'
18+
cache: 'maven'
19+
- uses: cucumber/[email protected]
20+
with:
21+
gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }}
22+
gpg-passphrase: ${{ secrets.GPG_PASSPHRASE }}
23+
nexus-username: ${{ secrets.SONATYPE_USERNAME }}
24+
nexus-password: ${{ secrets.SONATYPE_PASSWORD }}
25+
working-directory: java

.github/workflows/test-java.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: test-java
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- renovate/**
8+
paths:
9+
- java/**
10+
- testdata/**
11+
- .github/**
12+
pull_request:
13+
branches:
14+
- main
15+
paths:
16+
- java/**
17+
- testdata/**
18+
- .github/**
19+
workflow_call:
20+
21+
jobs:
22+
test-java:
23+
runs-on: ${{ matrix.os }}
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
os:
28+
- ubuntu-latest
29+
java: ["11", "17"]
30+
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- uses: actions/setup-java@v4
35+
with:
36+
distribution: "zulu"
37+
java-version: ${{ matrix.java }}
38+
cache: "maven"
39+
40+
- run: mvn verify
41+
working-directory: java
42+
test-java-pittest:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- uses: actions/checkout@v4
46+
- uses: actions/setup-java@v4
47+
with:
48+
distribution: "temurin"
49+
java-version: 17
50+
cache: "maven"
51+
- run: mvn test-compile org.pitest:pitest-maven:mutationCoverage
52+
working-directory: java

.github/workflows/test-testdata.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: test-testdata
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- testdata/compatibility-kit/**
9+
- testdata/json-schema/**
10+
- .github/**
11+
pull_request:
12+
branches:
13+
- main
14+
paths:
15+
- testdata/compatibility-kit/**
16+
- testdata/json-schema/**
17+
- .github/**
18+
19+
jobs:
20+
test-testdata-compatibility-kit:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v4
24+
- uses: actions/setup-node@v4
25+
with:
26+
cache: 'npm'
27+
cache-dependency-path: testdata/compatibility-kit/package-lock.json
28+
29+
- run: npm ci
30+
working-directory: testdata/compatibility-kit/
31+
32+
- name: check repository is not dirty
33+
run: "[[ -z $(git status --porcelain) ]]"
34+
35+
- name: show diff
36+
if: ${{ failure() }}
37+
run: git status --porcelain
38+
39+
test-testdata-json-schema:
40+
runs-on: ubuntu-latest
41+
steps:
42+
- uses: actions/checkout@v4
43+
- uses: actions/setup-node@v4
44+
with:
45+
cache: 'npm'
46+
cache-dependency-path: testdata/json-schema/package-lock.json
47+
48+
- run: npm ci
49+
working-directory: testdata/json-schema/
50+
51+
- name: check repository is not dirty
52+
run: "[[ -z $(git status --porcelain) ]]"
53+
54+
- name: show diff
55+
if: ${{ failure() }}
56+
run: git status --porcelain
57+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
*.iml

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [Unreleased]
9+
### Added
10+
- Java implementation ([#1](https://github.com/cucumber/cucumber-json-formatter/pull/1) M.P. Korstanje)
11+
12+
[Unreleased]: https://github.com/cucumber/cucumber-json-formatter/compare/6a8e0a16c2a96c1c134cf9f39604ec0b4afaaf9e...HEAD

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) M.P. Korstanje
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 78 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,81 @@
11
⚠️ This is an internal package; you don't need to install it in order to use the JSON Formatter.
22

3-
⚠️ The [Standalone JSON Formatter](https://github.com/cucumber/standalone-json-formatter) has moved.
4-
5-
# json-formatter
3+
# Cucumber JSON Formatter
64
Writes Cucumber message into the legacy Cucumber JSON format
5+
6+
The Cucumber JSON report is a de facto standard without specification. The standard
7+
also differs per Cucumber implementation.
8+
9+
For each language we validate this implementation against the implementation
10+
specific variants of the [cucumber-json-schema](https://github.com/cucumber/cucumber-json-schema)
11+
as well as the original implementation. So there should be a good chance your
12+
tooling will understand it.
13+
14+
## Features
15+
16+
Given a passing feature file:
17+
18+
```gherkin
19+
Feature: minimal
20+
21+
Scenario: cukes
22+
Given I have 42 cukes in my belly
23+
```
24+
25+
Cucumber reports the result in json as:
26+
27+
```json
28+
[
29+
{
30+
"line": 1,
31+
"uri": "samples/minimal/minimal.feature",
32+
"id": "minimal",
33+
"keyword": "Feature",
34+
"name": "minimal",
35+
"description": "",
36+
"elements": [
37+
{
38+
"start_timestamp": "1970-01-01T00:00:00.001Z",
39+
"line": 9,
40+
"id": "minimal;cukes",
41+
"type": "scenario",
42+
"keyword": "Scenario",
43+
"name": "cukes",
44+
"description": "",
45+
"steps": [
46+
{
47+
"keyword": "Given ",
48+
"line": 10,
49+
"match": {
50+
"location": "samples/minimal/minimal.feature.ts:3",
51+
"arguments": [
52+
{
53+
"val": "42",
54+
"offset": 7
55+
}
56+
]
57+
},
58+
"name": "I have 42 cukes in my belly",
59+
"result": {
60+
"duration": 1000000,
61+
"status": "passed"
62+
}
63+
}
64+
]
65+
}
66+
],
67+
"tags": [ ]
68+
}
69+
]
70+
```
71+
72+
## Maintenance mode
73+
74+
The Cucumber JSON format and formatter are in maintenance mode. For the new
75+
unified message format, see [cucumber-messages](https://github.com/cucumber/messages).
76+
77+
## Contributing
78+
79+
Each language implementation validates itself against the examples in the
80+
`testdata` folder. See the [testdata/README.md](testdata/README.md) for more
81+
information.

RELEASING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
See https://github.com/cucumber/.github/blob/main/RELEASING.md.

0 commit comments

Comments
 (0)