@@ -44,34 +44,20 @@ public class CucumberInstrumentation extends Instrumentation {
44
44
public static final String TAG = "cucumber-android" ;
45
45
46
46
private final Bundle results = new Bundle ();
47
- private boolean justCount ;
48
47
private int testCount ;
49
- private boolean coverage ;
50
- private String coverageFilePath ;
51
48
52
49
private RuntimeOptions runtimeOptions ;
53
50
private ResourceLoader resourceLoader ;
54
51
private ClassLoader classLoader ;
55
52
private Runtime runtime ;
56
- private boolean debug ;
57
53
private List <CucumberFeature > cucumberFeatures ;
54
+ InstrumentationArguments instrumentationArguments ;
58
55
59
56
@ Override
60
57
public void onCreate (Bundle arguments ) {
61
58
super .onCreate (arguments );
62
59
63
- if (arguments != null ) {
64
- debug = getBooleanArgument (arguments , "debug" );
65
- boolean logOnly = getBooleanArgument (arguments , "log" );
66
- if (logOnly && arguments .getString ("dryRun" ) == null ) {
67
- arguments .putString ("dryRun" , "true" );
68
- }
69
- justCount = getBooleanArgument (arguments , "count" );
70
- coverage = getBooleanArgument (arguments , "coverage" );
71
- coverageFilePath = arguments .getString ("coverageFile" );
72
- }
73
-
74
- InstrumentationArguments instrumentationArguments = new InstrumentationArguments (arguments );
60
+ instrumentationArguments = new InstrumentationArguments (arguments );
75
61
76
62
Context context = getContext ();
77
63
classLoader = context .getClassLoader ();
@@ -126,12 +112,12 @@ private DexFile newDexFile(String apkPath) {
126
112
public void onStart () {
127
113
Looper .prepare ();
128
114
129
- if (justCount ) {
115
+ if (instrumentationArguments . isCountEnabled () ) {
130
116
results .putString (Instrumentation .REPORT_KEY_IDENTIFIER , REPORT_VALUE_ID );
131
117
results .putInt (REPORT_KEY_NUM_TOTAL , testCount );
132
118
finish (Activity .RESULT_OK , results );
133
119
} else {
134
- if (debug ) {
120
+ if (instrumentationArguments . isDebugEnabled () ) {
135
121
Debug .waitForDebugger ();
136
122
}
137
123
@@ -150,7 +136,7 @@ public void onStart() {
150
136
151
137
printSummary ();
152
138
153
- if (coverage ) {
139
+ if (instrumentationArguments . isCoverageEnabled () ) {
154
140
generateCoverageReport ();
155
141
}
156
142
@@ -168,11 +154,6 @@ private void printSummary() {
168
154
}
169
155
}
170
156
171
- private boolean getBooleanArgument (Bundle arguments , String tag ) {
172
- String tagString = arguments .getString (tag );
173
- return tagString != null && Boolean .parseBoolean (tagString );
174
- }
175
-
176
157
private void generateCoverageReport () {
177
158
// use reflection to call emma dump coverage method, to avoid
178
159
// always statically compiling against emma jar
@@ -209,6 +190,7 @@ private void generateCoverageReport() {
209
190
}
210
191
211
192
private String getCoverageFilePath () {
193
+ String coverageFilePath = instrumentationArguments .getCoverageFilePath ();
212
194
if (coverageFilePath == null ) {
213
195
return getTargetContext ().getFilesDir ().getAbsolutePath () + File .separator +
214
196
DEFAULT_COVERAGE_FILE_NAME ;
0 commit comments