-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test optimization] Add dynamic instrumentation support for cucumber (#…
- Loading branch information
1 parent
844d623
commit 3296eb8
Showing
8 changed files
with
311 additions
and
11 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
24 changes: 24 additions & 0 deletions
24
integration-tests/ci-visibility/features-di/support/steps.js
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,24 @@ | ||
const assert = require('assert') | ||
const { When, Then } = require('@cucumber/cucumber') | ||
const sum = require('./sum') | ||
|
||
let count = 0 | ||
|
||
When('the greeter says hello', function () { | ||
this.whatIHeard = 'hello' | ||
}) | ||
|
||
Then('I should have heard {string}', function (expectedResponse) { | ||
sum(11, 3) | ||
assert.equal(this.whatIHeard, expectedResponse) | ||
}) | ||
|
||
Then('I should have flakily heard {string}', function (expectedResponse) { | ||
const shouldFail = count++ < 1 | ||
if (shouldFail) { | ||
sum(11, 3) | ||
} else { | ||
sum(1, 3) // does not hit the breakpoint the second time | ||
} | ||
assert.equal(this.whatIHeard, expectedResponse) | ||
}) |
10 changes: 10 additions & 0 deletions
10
integration-tests/ci-visibility/features-di/support/sum.js
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,10 @@ | ||
function funSum (a, b) { | ||
const localVariable = 2 | ||
if (a > 10) { | ||
throw new Error('the number is too big') | ||
} | ||
|
||
return a + b + localVariable | ||
} | ||
|
||
module.exports = funSum |
6 changes: 6 additions & 0 deletions
6
integration-tests/ci-visibility/features-di/test-hit-breakpoint.feature
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,6 @@ | ||
|
||
Feature: Greeting | ||
|
||
Scenario: Say hello | ||
When the greeter says hello | ||
Then I should have heard "hello" |
6 changes: 6 additions & 0 deletions
6
integration-tests/ci-visibility/features-di/test-not-hit-breakpoint.feature
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,6 @@ | ||
|
||
Feature: Greeting | ||
|
||
Scenario: Say hello | ||
When the greeter says hello | ||
Then I should have flakily heard "hello" |
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
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
Oops, something went wrong.