Enable dynamic scenario naming#150
Enable dynamic scenario naming#150radekvonboktor wants to merge 2 commits intoreportportal:developfrom
Conversation
|
Hi, @radekvonboktor! |
| } | ||
|
|
||
| const { name: scenarioName } = scenario; | ||
| const scenarioName = this.storage.getPickle(pickleId).name; |
There was a problem hiding this comment.
@radekvonboktor Hi, there!
gherkin creates ast.
And every AST node such as pickle in our case, associates with the scenario through ASTNodeID
I mean, that pickle and scenario are almost the same entities.

And as I can see, dynamic scenario naming already works fine.
Maybe I missed something. Could you please provide an example, where the scenario naming does not contain the value of the variable?
|
Hey @Bam6ycha. Will take a look at it as soon as possible. There is a huge possibility that in the context of our framework, we might be doing something different that causes the dynamic names not to work as expected, as we use a custom reporter to generate the cucumber-report.html. So what I will do:
Thanks :) |
|
Hey @Bam6ycha sorry for taking so long to get back to this, but you know how it is :) So I've updated cucumber to version 9.6.0 and agent-js-cucumber to 5.2.2. So by the looks of it, the js agent here, picks up the name from $.gherkinDocument..children[*].scenario..name variable. But our dynamic name is in the pickle object. You can see the whole object below. {
"gherkinDocument":{
"feature":{
"tags":[
{
"location":{
"line":1,
"column":1
},
"name":"@RPdebug",
"id":"24d692eb-885a-4eaa-bc33-ecc95aa41f01"
}
],
"location":{
"line":2,
"column":1
},
"language":"en",
"keyword":"Feature",
"name":"Debug dynamic naming",
"description":"",
"children":[
{
"scenario":{
"id":"819345a2-e8a0-4fc3-9990-ea12c0a1acd5",
"tags":[
],
"location":{
"line":4,
"column":5
},
"keyword":"Scenario Outline",
"name":"[Single Market - <market>] Dynamic name",
"description":"",
"steps":[
{
"id":"164c7c6e-4234-4050-88b3-e595991b47bb",
"location":{
"line":5,
"column":9
},
"keyword":"Given ",
"keywordType":"Context",
"text":"wait for 2 seconds"
}
],
"examples":[
{
"id":"91ab74e6-3afa-48e9-a739-28ede70c14a2",
"tags":[
],
"location":{
"line":7,
"column":9
},
"keyword":"Examples",
"name":"",
"description":"",
"tableHeader":{
"id":"12773396-f52c-4285-ab17-a17d6f34a571",
"location":{
"line":8,
"column":13
},
"cells":[
{
"location":{
"line":8,
"column":15
},
"value":"market"
}
]
},
"tableBody":[
{
"id":"d73b810b-0e3e-44c9-b6da-3f1c5b072729",
"location":{
"line":9,
"column":13
},
"cells":[
{
"location":{
"line":9,
"column":15
},
"value":"US"
}
]
}
]
}
]
}
}
]
},
"comments":[
],
"uri":"features/scenarios/functionalities/baskets/RP_debug.feature"
},
"pickle":{
"id":"30956257-bd48-4c62-8519-5e3abdc3ba22",
"uri":"features/scenarios/functionalities/baskets/RP_debug.feature",
"astNodeIds":[
"819345a2-e8a0-4fc3-9990-ea12c0a1acd5",
"d73b810b-0e3e-44c9-b6da-3f1c5b072729"
],
"name":"[Single Market - US] Dynamic name",
"language":"en",
"steps":[
{
"id":"ecf07497-b5cb-4ee5-a8aa-deee34e3d653",
"text":"wait for 2 seconds",
"type":"Context",
"astNodeIds":[
"164c7c6e-4234-4050-88b3-e595991b47bb",
"d73b810b-0e3e-44c9-b6da-3f1c5b072729"
]
}
],
"tags":[
{
"name":"@RPdebug",
"astNodeId":"24d692eb-885a-4eaa-bc33-ecc95aa41f01"
}
]
},
"testCaseStartedId":"1dca81c7-c1a2-461e-b2d3-c40524bf1d2a"
}This is how it looks like in Report Portal: For a bit more context, this is what the object looks like, from which the scenarioName gets declared in agent-js-cucumber: const { name: scenarioName } = scenario;{
id: '263aae5e-57f1-417a-9e33-0bf94f5afc7c',
tags: [],
location: { line: 4, column: 5 },
keyword: 'Scenario Outline',
name: '[Single Market - <market>] Dynamic name',
description: '',
steps: [
{
id: 'efa20d8e-5950-419e-aab8-d9ea2c1d4f4e',
location: [Object],
keyword: 'Given ',
keywordType: 'Context',
text: 'wait for 2 seconds',
dataTable: undefined,
docString: undefined
}
],
examples: [
{
id: 'b321ded0-64b6-497a-8b75-aa3f1a6f7507',
tags: [],
location: [Object],
keyword: 'Examples',
name: '',
description: '',
tableHeader: [Object],
tableBody: [Array]
}
]
}That's why with my change, I want to pick the name of the currently executed scenario from the pickle object: const scenarioName = this.storage.getPickle(pickleId).name;The pickle for that scenario looks like this: {
id: '1e21fa24-88c9-4b40-bdb0-f8f2fd83ee95',
uri: 'features/scenarios/functionalities/baskets/RP_debug.feature',
astNodeIds: [
'382bdb9f-06c9-4180-85fc-d9ce345ef2c8',
'9a83e3af-c184-4db8-9192-9396f6987ad9'
],
name: '[Single Market - US] Dynamic name',
language: 'en',
steps: [
{
id: 'e162a895-5ac5-4261-863c-1a8fd63f10f5',
text: 'wait for 2 seconds',
type: 'Context',
argument: undefined,
astNodeIds: [Array]
}
],
tags: [
{
name: '@RPdebug',
astNodeId: '6971f499-9f98-4dec-9269-3bfd385c576e'
}
]
} |




This change allows us to use dynamic scenario naming.
Part of a fix for this issue #149