21
21
22
22
final class PickleRunners {
23
23
24
- static PickleRunner withStepDescriptions (RunnerSupplier runnerSupplier , Pickle pickle , JUnitOptions options ) {
24
+ static PickleRunner withStepDescriptions (
25
+ RunnerSupplier runnerSupplier , Pickle pickle , Integer uniqueSuffix , JUnitOptions options
26
+ ) {
25
27
try {
26
- return new WithStepDescriptions (runnerSupplier , pickle , options );
28
+ return new WithStepDescriptions (runnerSupplier , pickle , uniqueSuffix , options );
27
29
} catch (InitializationError e ) {
28
30
throw new CucumberException ("Failed to create scenario runner" , e );
29
31
}
30
32
}
31
33
32
34
static PickleRunner withNoStepDescriptions (
33
- String featureName , RunnerSupplier runnerSupplier , Pickle pickle , JUnitOptions jUnitOptions
35
+ String featureName , RunnerSupplier runnerSupplier , Pickle pickle , Integer uniqueSuffix ,
36
+ JUnitOptions jUnitOptions
34
37
) {
35
- return new NoStepDescriptions (featureName , runnerSupplier , pickle , jUnitOptions );
38
+ return new NoStepDescriptions (featureName , runnerSupplier , pickle , uniqueSuffix , jUnitOptions );
36
39
}
37
40
38
41
interface PickleRunner {
@@ -51,14 +54,18 @@ static class WithStepDescriptions extends ParentRunner<Step> implements PickleRu
51
54
private final Pickle pickle ;
52
55
private final JUnitOptions jUnitOptions ;
53
56
private final Map <Step , Description > stepDescriptions = new HashMap <>();
57
+ private final Integer uniqueSuffix ;
54
58
private Description description ;
55
59
56
- WithStepDescriptions (RunnerSupplier runnerSupplier , Pickle pickle , JUnitOptions jUnitOptions )
60
+ WithStepDescriptions (
61
+ RunnerSupplier runnerSupplier , Pickle pickle , Integer uniqueSuffix , JUnitOptions jUnitOptions
62
+ )
57
63
throws InitializationError {
58
64
super ((Class <?>) null );
59
65
this .runnerSupplier = runnerSupplier ;
60
66
this .pickle = pickle ;
61
67
this .jUnitOptions = jUnitOptions ;
68
+ this .uniqueSuffix = uniqueSuffix ;
62
69
}
63
70
64
71
@ Override
@@ -70,7 +77,7 @@ protected List<Step> getChildren() {
70
77
71
78
@ Override
72
79
protected String getName () {
73
- return createName (pickle .getName (), jUnitOptions .filenameCompatibleNames ());
80
+ return createName (pickle .getName (), uniqueSuffix , jUnitOptions .filenameCompatibleNames ());
74
81
}
75
82
76
83
@ Override
@@ -86,8 +93,9 @@ public Description getDescription() {
86
93
public Description describeChild (Step step ) {
87
94
Description description = stepDescriptions .get (step );
88
95
if (description == null ) {
89
- String testName = createName (step .getText (), jUnitOptions .filenameCompatibleNames ());
90
- description = Description .createTestDescription (getName (), testName , new PickleStepId (pickle , step ));
96
+ String className = getName ();
97
+ String name = createName (step .getText (), jUnitOptions .filenameCompatibleNames ());
98
+ description = Description .createTestDescription (className , name , new PickleStepId (pickle , step ));
91
99
stepDescriptions .put (step , description );
92
100
}
93
101
return description ;
@@ -120,15 +128,18 @@ static final class NoStepDescriptions implements PickleRunner {
120
128
private final RunnerSupplier runnerSupplier ;
121
129
private final Pickle pickle ;
122
130
private final JUnitOptions jUnitOptions ;
131
+ private final Integer uniqueSuffix ;
123
132
private Description description ;
124
133
125
134
NoStepDescriptions (
126
- String featureName , RunnerSupplier runnerSupplier , Pickle pickle , JUnitOptions jUnitOptions
135
+ String featureName , RunnerSupplier runnerSupplier , Pickle pickle , Integer uniqueSuffix ,
136
+ JUnitOptions jUnitOptions
127
137
) {
128
138
this .featureName = featureName ;
129
139
this .runnerSupplier = runnerSupplier ;
130
140
this .pickle = pickle ;
131
141
this .jUnitOptions = jUnitOptions ;
142
+ this .uniqueSuffix = uniqueSuffix ;
132
143
}
133
144
134
145
@ Override
@@ -145,7 +156,7 @@ public void run(final RunNotifier notifier) {
145
156
public Description getDescription () {
146
157
if (description == null ) {
147
158
String className = createName (featureName , jUnitOptions .filenameCompatibleNames ());
148
- String name = createName (pickle .getName (), jUnitOptions .filenameCompatibleNames ());
159
+ String name = createName (pickle .getName (), uniqueSuffix , jUnitOptions .filenameCompatibleNames ());
149
160
description = Description .createTestDescription (className , name , new PickleId (pickle ));
150
161
}
151
162
return description ;
0 commit comments