Skip to content

Commit 4ac519d

Browse files
committed
Cucumber Performance - Version 2.0.1
Changes: 1) Summary formatter now matches Java output Fixes: 1) Summary and CSV formatter updated to convert output data type. 2) Summary formatter and Taurus formatter updated to output milliseconds.
1 parent 327ff18 commit 4ac519d

File tree

12 files changed

+134
-74
lines changed

12 files changed

+134
-74
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cucumber-perf",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"description": "The js implimentation of Cucumber-Perf",
55
"keywords": [
66
"testing",
@@ -36,7 +36,7 @@
3636
"lib/"
3737
],
3838
"scripts": {
39-
"feature-test": "node ./bin/cucumber-perf -p test\\plans\\ --plan-tags @simPos -f progress test\\features\\",
39+
"feature-test": "node ./bin/cucumber-perf -p test\\plans\\ --plan-tags @simPos -f progress -f summary test\\features\\",
4040
"build-local": "babel src -d lib --copy-files --no-copy-ignored --config-file ./build.babelrc",
4141
"build-local-test": "babel test/steps -d test/features/steps --config-file ./build.babelrc'",
4242
"lint-autofix": "eslint --fix \"{example,features,scripts,src,test}/**/*.js\"",

src/formatter/helpers/csv_helpers.js

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,35 @@
1-
export function formatCSV({ colorFns, heading, statOrder, testRun }) {
1+
import { convertOutput } from './summary_helpers'
2+
3+
export function formatCSV({
4+
colorFns,
5+
heading,
6+
statOrder,
7+
displayType,
8+
testRun,
9+
}) {
210
let rows = ''
311
testRun.groups.forEach(group => {
412
let v = getGroupLines({
513
colorFns: colorFns,
614
group: group,
715
statOrder: statOrder,
16+
displayType: displayType,
817
statTypes: testRun.statTypes,
918
})
1019
rows += v
1120
})
1221
return [colorFns['simulationTitle'](heading), rows].join('\n')
1322
}
1423

15-
function getGroupLines({ colorFns, group, statOrder, statTypes }) {
24+
function getGroupLines({ colorFns, group, statOrder, displayType, statTypes }) {
1625
let gt = colorFns['groupTitle'](group.text)
1726
let text =
1827
gt +
1928
getStatistics({
2029
object: group,
2130
statOrder: statOrder,
2231
statTypes: statTypes,
32+
displayType: displayType,
2333
}) +
2434
'\n'
2535
group.testCases.forEach(testCase => {
@@ -31,6 +41,7 @@ function getGroupLines({ colorFns, group, statOrder, statTypes }) {
3141
object: testCase,
3242
statOrder: statOrder,
3343
statTypes: statTypes,
44+
displayType: displayType,
3445
}) +
3546
'\n'
3647
testCase.steps.forEach(step => {
@@ -43,24 +54,37 @@ function getGroupLines({ colorFns, group, statOrder, statTypes }) {
4354
object: step,
4455
statOrder: statOrder,
4556
statTypes: statTypes,
57+
displayType: displayType,
4658
}) +
4759
'\n'
4860
})
4961
})
5062
return text
5163
}
5264

53-
function getStatistics({ object, statOrder, statTypes }) {
65+
function getStatistics({ object, statOrder, statTypes, displayType }) {
5466
let text = ''
5567
for (let stat of statOrder) {
5668
if (statTypes.hasOwnProperty(stat.key)) {
5769
if (
5870
statTypes[stat.key].isFloatingPoint &&
5971
object.stats[stat.key] != null
6072
) {
61-
text += ',' + object.stats[stat.key].toFixed(3)
73+
text +=
74+
',' +
75+
convertOutput(
76+
displayType,
77+
statTypes[stat.key].dataType,
78+
object.stats[stat.key]
79+
).toFixed(3)
6280
} else {
63-
text += ',' + object.stats[stat.key]
81+
text +=
82+
',' +
83+
convertOutput(
84+
displayType,
85+
statTypes[stat.key].dataType,
86+
object.stats[stat.key]
87+
)
6488
}
6589
} else {
6690
text += ',' + stat.default

src/formatter/helpers/summary_helpers.js

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,82 @@
11
import { statDataType } from '../statistics'
22

33
export function convertOutput(displayType, dataType, value) {
4-
let output = ''
5-
if (dataType === statDataType.COUNT || dataType === statDataType.OTHER) {
6-
output = value
7-
} else if (displayType !== dataType) {
4+
let output = value
5+
if (
6+
!(dataType === statDataType.COUNT || dataType === statDataType.OTHER) &&
7+
displayType !== dataType
8+
) {
89
if (
910
dataType === statDataType.NANOS &&
1011
displayType === statDataType.MILLIS
1112
) {
12-
output = output + value / 1000000
13+
output = value / 1000000
1314
} else if (
1415
dataType === statDataType.MILLIS &&
1516
displayType === statDataType.NANOS
1617
) {
17-
output = output + value * 1000000
18+
output = value * 1000000
1819
} else if (
1920
dataType === statDataType.MILLIS &&
2021
displayType === statDataType.SECONDS
2122
) {
22-
output = output + value / 1000
23+
output = value / 1000
2324
} else if (
2425
dataType === statDataType.NANOS &&
2526
displayType === statDataType.SECONDS
2627
) {
27-
output = output + value / 1000000000
28+
output = value / 1000000000
2829
} else if (
2930
dataType === statDataType.SECONDS &&
3031
displayType === statDataType.MILLIS
3132
) {
32-
output = output + value * 1000
33+
output = value * 1000
3334
} else if (
3435
dataType === statDataType.SECONDS &&
3536
displayType === statDataType.NANOS
3637
) {
37-
output = output + value * 1000000000
38+
output = value * 1000000000
3839
}
39-
} else {
40-
output = output + value
4140
}
4241
return output
4342
}
4443

45-
export function formatSummary({ colorFns, testRun }) {
44+
export function formatSummary({ displayType, colorFns, testRun }) {
4645
let groupSummarys = ''
4746
testRun.groups.forEach((group, index) => {
4847
let v = getGroupSummary({
4948
colorFns: colorFns,
5049
group: group,
5150
statTypes: testRun.statTypes,
51+
displayType: displayType,
5252
})
5353
groupSummarys += v
5454
})
5555
const durationSummary = getDuration(testRun.duration)
5656
return [
57-
colorFns['simulationTitle']('Simulation: ') + testRun.name,
57+
colorFns['simulationTitle']('Simulation: ') +
58+
testRun.name +
59+
colorFns['statTitle'](' Start: ') +
60+
testRun.start +
61+
colorFns['statTitle'](' Stop: ') +
62+
testRun.stop +
63+
colorFns['statTitle'](' Duration: ') +
64+
durationSummary,
5865
groupSummarys,
59-
'Runtime: ' + durationSummary,
6066
].join('\n')
6167
}
6268

63-
function getGroupSummary({ colorFns, group, statTypes }) {
69+
function getGroupSummary({ colorFns, group, statTypes, displayType }) {
6470
let text =
6571
colorFns['groupTitle']('Group: ') +
6672
group.text +
6773
' ' +
68-
getStatistics({ colorFns: colorFns, object: group, statTypes: statTypes }) +
74+
getStatistics({
75+
colorFns: colorFns,
76+
object: group,
77+
statTypes: statTypes,
78+
displayType: displayType,
79+
}) +
6980
'\n'
7081
group.testCases.forEach(testCase => {
7182
text +=
@@ -77,6 +88,7 @@ function getGroupSummary({ colorFns, group, statTypes }) {
7788
colorFns: colorFns,
7889
object: testCase,
7990
statTypes: statTypes,
91+
displayType: displayType,
8092
}) +
8193
'\n'
8294
testCase.steps.forEach(step => {
@@ -89,20 +101,29 @@ function getGroupSummary({ colorFns, group, statTypes }) {
89101
colorFns: colorFns,
90102
object: step,
91103
statTypes: statTypes,
104+
displayType: displayType,
92105
}) +
93106
'\n'
94107
})
95108
})
96109
return text
97110
}
98111

99-
function getStatistics({ colorFns, object, statTypes }) {
112+
function getStatistics({ colorFns, object, statTypes, displayType }) {
100113
let text = ''
101114
for (let stat in statTypes) {
102115
if (statTypes[stat].isFloatingPoint && object.stats[stat] != null) {
103-
text += `${colorFns['statTitle'](stat)}:${object.stats[stat].toFixed(3)} `
116+
text += `${colorFns['statTitle'](stat)}:${convertOutput(
117+
displayType,
118+
statTypes[stat].dataType,
119+
object.stats[stat]
120+
).toFixed(3)} `
104121
} else {
105-
text += `${colorFns['statTitle'](stat)}:${object.stats[stat]} `
122+
text += `${colorFns['statTitle'](stat)}:${convertOutput(
123+
displayType,
124+
statTypes[stat].dataType,
125+
object.stats[stat]
126+
)} `
106127
}
107128
}
108129
return text

src/formatter/helpers/summary_helpers_spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ describe('SummaryHelpers', () => {
7070

7171
it('outputs step totals, scenario totals, and duration', function() {
7272
expect(this.result).to.contain(
73-
'Simulation: simulation\n\nRuntime: 0:0:0.0'
73+
'Simulation: simulation Start: 2019-06-04T14:10:24Z Stop: 2019-06-04T22:10:24Z Duration: 0:0:0.0\n'
7474
)
7575
})
7676
})
@@ -122,7 +122,7 @@ describe('SummaryHelpers', () => {
122122

123123
it('outputs the totals and number of each status', function() {
124124
expect(this.result).to.contain(
125-
'Simulation: simulation\nGroup: a.feature avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\tScenario: test case avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\nRuntime: 0:0:0.0'
125+
'Simulation: simulation Start: 2019-06-04T14:10:24Z Stop: 2019-06-04T22:10:24Z Duration: 0:0:0.0\nGroup: a.feature avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\tScenario: test case avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n'
126126
)
127127
})
128128
})
@@ -174,7 +174,7 @@ describe('SummaryHelpers', () => {
174174

175175
it('filter out the hooks', function() {
176176
expect(this.result).to.contain(
177-
'Simulation: simulation\nGroup: a.feature avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\tScenario: test case avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\nRuntime: 0:0:0.0'
177+
'Simulation: simulation Start: 2019-06-04T14:10:24Z Stop: 2019-06-04T22:10:24Z Duration: 0:0:0.0\nGroup: a.feature avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\tScenario: test case avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n'
178178
)
179179
})
180180
})
@@ -238,7 +238,7 @@ describe('SummaryHelpers', () => {
238238

239239
it('outputs the totals and number of each status', function() {
240240
expect(this.result).to.contain(
241-
'Simulation: simulation\nGroup: a.feature avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\tScenario: test case avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\nRuntime: 0:0:0.0'
241+
'Simulation: simulation Start: 2019-06-04T14:10:24Z Stop: 2019-06-04T22:10:24Z Duration: 0:0:0.0\nGroup: a.feature avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\tScenario: test case avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n'
242242
)
243243
})
244244
})
@@ -416,14 +416,14 @@ describe('SummaryHelpers', () => {
416416

417417
it('outputs the totals and number of each status', function() {
418418
expect(this.result).to.contain(
419-
'Simulation: simulation\nGroup: a.feature avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t' +
419+
'Simulation: simulation Start: 2019-06-04T14:10:24Z Stop: 2019-06-04T22:10:24Z Duration: 0:0:0.0\nGroup: a.feature avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t' +
420420
'Scenario: tc passed avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t' +
421421
'Scenario: tc failed avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t' +
422422
'Scenario: tc ambigious avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t' +
423423
'Scenario: tc pending avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t' +
424424
'Scenario: tc skipped avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\tStep: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t' +
425425
'Scenario: tc undefined avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\t\t' +
426-
'Step: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n\nRuntime: 0:0:0.0'
426+
'Step: step a avg:0.000 cncrnt:0.000 cnt:0 max:0 min:0 \n'
427427
)
428428
})
429429
})
@@ -436,7 +436,7 @@ describe('SummaryHelpers', () => {
436436

437437
it('outputs the duration as 0m00.123s', function() {
438438
expect(this.result).to.contain(
439-
'Simulation: simulation\n\nRuntime: 0:0:0.123'
439+
'Simulation: simulation Start: 2019-06-04T14:10:24Z Stop: 2019-06-04T22:10:24Z Duration: 0:0:0.123\n'
440440
)
441441
})
442442
})
@@ -449,7 +449,7 @@ describe('SummaryHelpers', () => {
449449

450450
it('outputs the duration as 0m12.300s', function() {
451451
expect(this.result).to.contain(
452-
'Simulation: simulation\n\nRuntime: 0:0:12.300'
452+
'Simulation: simulation Start: 2019-06-04T14:10:24Z Stop: 2019-06-04T22:10:24Z Duration: 0:0:12.300\n'
453453
)
454454
})
455455
})
@@ -462,7 +462,7 @@ describe('SummaryHelpers', () => {
462462

463463
it('outputs the duration as 2m03.000s', function() {
464464
expect(this.result).to.contain(
465-
'Simulation: simulation\n\nRuntime: 0:2:3.0'
465+
'Simulation: simulation Start: 2019-06-04T14:10:24Z Stop: 2019-06-04T22:10:24Z Duration: 0:2:3.0\n'
466466
)
467467
})
468468
})

src/formatter/summary_formatter.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import _ from 'lodash'
22
import { formatIssue, formatSummary } from './helpers'
3+
import { statDataType } from './statistics'
34
import Formatter from '.'
45

56
export default class SummaryFormatter extends Formatter {
@@ -12,8 +13,10 @@ export default class SummaryFormatter extends Formatter {
1213
}
1314

1415
logSummary(result) {
16+
if (this.isStdio()) this.log('\n')
1517
this.log(
1618
formatSummary({
19+
displayType: statDataType.MILLIS,
1720
colorFns: this.colorFns,
1821
testRun: result,
1922
})

0 commit comments

Comments
 (0)