-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 02cb296
Showing
9 changed files
with
1,941 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
test-suites: | ||
captain-examples-cucumber-js: | ||
command: npx cucumber-js --format json:tmp/cucumber.json --format summary --retry 1 --retry-tag-filter @flaky | ||
results: | ||
language: JavaScript | ||
framework: Cucumber | ||
path: tmp/cucumber.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: "Captain Cucumber Integration Example" | ||
on: | ||
- push | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22.x | ||
- uses: rwx-research/setup-captain@v1 | ||
- run: npm install | ||
- run: captain run captain-examples-cucumber-js | ||
env: | ||
RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# MIT LICENSE | ||
|
||
Copyright (c) 2022 ReadWriteExecute, Inc. and contributors | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Getting Captain working with Cucumber | ||
|
||
To configure cucumber-js such that it works with Captain, we need to: | ||
|
||
1. 🧪 Ensure cucumber produces json output | ||
|
||
`cucumber-js --format json:tmp/cucumber.json` will produce Captain-compatible JSON output in `tmp/cucumber.json`. | ||
To ensure GitHub logs continue to have test output, also include a stdout-friendly formatter (for example, `--format summary`) | ||
|
||
```yaml | ||
# .captain/config.yaml | ||
test-suites: | ||
captain-examples-cucumber-js: | ||
command: cucumber-js --format json:tmp/cucumber.json --format summary | ||
results: | ||
language: JavaScript | ||
framework: Cucumber | ||
path: tmp/cucumber.json | ||
``` | ||
2. 🔐 Create an Access Token | ||
Create an Access Token for your organization within [Captain][captain] ([more documentation here][create-access-token]). | ||
Add the new token as an action secret to your repository. Conventionally, we call this secret `RWX_ACCESS_TOKEN`. | ||
|
||
3. 💌 Install the Captain CLI, and then call it when running tests | ||
|
||
See the [full documentation on test suite integration][test-suite-integration]. | ||
|
||
```yaml | ||
- uses: rwx-research/setup-captain@v1 | ||
- run: captain run captain-examples-cucumber-js | ||
env: | ||
RWX_ACCESS_TOKEN: ${{ secrets.RWX_ACCESS_TOKEN }} | ||
``` | ||
|
||
4. 🎉 See your test results in Captain! | ||
|
||
Take a look at the [final workflow!][workflow-with-captain] | ||
|
||
[captain]: https://account.rwx.com/deep_link/manage/access_tokens | ||
[create-access-token]: https://www.rwx.com/docs/access-tokens | ||
[workflow-with-captain]: https://github.com/captain-examples/cucumber-ruby/blob/main/.github/workflows/ci.yml | ||
[test-suite-integration]: https://www.rwx.com/captain/docs/test-suite-integration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@feature_tag | ||
Feature: Rule Sample | ||
|
||
@rule_tag | ||
Rule: This is a rule | ||
|
||
Example: A passing example | ||
Given this will pass | ||
When I do an action | ||
Then some results should be there | ||
|
||
@flaky | ||
@failing | ||
Example: A failing example | ||
Given this will fail | ||
When I do an action | ||
Then some results should be there | ||
|
||
Example: A pending example | ||
Given this is pending | ||
When I do an action | ||
Then nothing should happen | ||
|
||
Example: A skipped example | ||
Given this is skipped | ||
When I do an action | ||
Then nothing should happen | ||
|
||
Example: An undefined example | ||
Given this is undefined | ||
When I do an action | ||
Then nothing should happen | ||
|
||
@failing_before_hook | ||
Example: With a failing before hook | ||
Given this will pass | ||
When I do an action | ||
Then some results should be there | ||
|
||
@failing_after_hook | ||
Example: With a failing after hook | ||
Given this will pass | ||
When I do an action | ||
Then some results should be there |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const assert = require("assert"); | ||
const { After, Before, Given, When, Then } = require("@cucumber/cucumber"); | ||
|
||
Given("this will pass", async function () { | ||
await new Promise((resolve) => setTimeout(resolve, 2000)); | ||
this.this_will_pass = true; | ||
}); | ||
|
||
Given("this will fail", function () { | ||
this.this_will_pass = false; | ||
}); | ||
|
||
When("I do an action", function () {}); | ||
|
||
Then("some results should be there", function () { | ||
assert(this.this_will_pass === true); | ||
}); | ||
|
||
Given("this is pending", function () { | ||
return "pending"; | ||
}); | ||
|
||
Given(/skip/, function () { | ||
return "skipped"; | ||
}); | ||
|
||
Before("@failing_before_hook", function (scenario) { | ||
throw new Error("failed in before hook"); | ||
}); | ||
|
||
After("@failing_after_hook", function (scenario) { | ||
throw new Error("failed in after hook"); | ||
}); |
Oops, something went wrong.