Skip to content

Commit b0e36c9

Browse files
committed
REnames
1 parent 5040333 commit b0e36c9

File tree

4 files changed

+61
-70
lines changed

4 files changed

+61
-70
lines changed

android-test/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,11 @@
2222
<dependency>
2323
<groupId>com.google.android</groupId>
2424
<artifactId>android</artifactId>
25-
<version>2.2.1</version>
2625
<scope>provided</scope>
2726
</dependency>
2827
<dependency>
2928
<groupId>com.google.android</groupId>
3029
<artifactId>android-test</artifactId>
31-
<version>2.2.1</version>
3230
<scope>provided</scope>
3331
</dependency>
3432
<dependency>
@@ -54,7 +52,7 @@
5452
<plugin>
5553
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
5654
<artifactId>android-maven-plugin</artifactId>
57-
<version>3.6.0</version>
55+
<version>${android-maven-plugin.version}</version>
5856
<extensions>true</extensions>
5957
</plugin>
6058
</plugins>

android/pom.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,11 @@
1818
<dependency>
1919
<groupId>com.google.android</groupId>
2020
<artifactId>android</artifactId>
21-
<version>2.2.1</version>
2221
<scope>provided</scope>
2322
</dependency>
2423
<dependency>
2524
<groupId>com.google.android</groupId>
2625
<artifactId>android-test</artifactId>
27-
<version>2.2.1</version>
2826
<scope>provided</scope>
2927
</dependency>
3028
<dependency>
@@ -46,7 +44,7 @@
4644
<plugin>
4745
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
4846
<artifactId>android-maven-plugin</artifactId>
49-
<version>3.6.0</version>
47+
<version>${android-maven-plugin.version}</version>
5048
<extensions>true</extensions>
5149
</plugin>
5250
</plugins>

android/src/cucumber/api/android/CucumberInstrumentation.java

Lines changed: 44 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,6 @@ public void onCreate(Bundle arguments) {
5757
if (arguments == null) {
5858
throw new CucumberException("No arguments");
5959
}
60-
Log.d(TAG, "************** KEYS **************");
61-
for (String key : arguments.keySet()) {
62-
Log.d(TAG, key + " => " + arguments.get(key));
63-
}
64-
/*
65-
MAVEN:
66-
log => false
67-
coverage => false
68-
coverageFile => expression
69-
debug => false
70-
71-
IDEA:
72-
class => cucumber.android.test.CucumberActivitySteps
73-
debug => false
74-
*/
75-
76-
77-
// Maven: [log, coverage, coverageFile, debug]
78-
// IDEA: [log, coverage, coverageFile, debug]
79-
8060
Context context = getContext();
8161
classLoader = context.getClassLoader();
8262

@@ -215,81 +195,81 @@ private void printSummary() {
215195
* It also wraps the AndroidFormatter to intercept important callbacks.
216196
*/
217197
private class AndroidReporter implements Formatter, Reporter {
218-
private final AndroidFormatter mFormatter;
219-
private final Bundle mResultTemplate;
220-
private Bundle mTestResult;
221-
private int mScenarioNum;
222-
private int mTestResultCode;
223-
private Feature mFeature;
224-
private Step mStep;
198+
private final AndroidFormatter formatter;
199+
private final Bundle resultTemplate;
200+
private Bundle testResult;
201+
private int scenarioCounter;
202+
private int resultCode; // aka exit status
203+
private Feature currentFeature;
204+
private Step currentStep;
225205

226206
public AndroidReporter(int numTests) {
227-
mFormatter = new AndroidFormatter(TAG);
228-
mResultTemplate = new Bundle();
229-
mResultTemplate.putString(Instrumentation.REPORT_KEY_IDENTIFIER, REPORT_VALUE_ID);
230-
mResultTemplate.putInt(REPORT_KEY_NUM_TOTAL, numTests);
207+
formatter = new AndroidFormatter(TAG);
208+
resultTemplate = new Bundle();
209+
resultTemplate.putString(Instrumentation.REPORT_KEY_IDENTIFIER, REPORT_VALUE_ID);
210+
resultTemplate.putInt(REPORT_KEY_NUM_TOTAL, numTests);
231211
}
232212

233213
@Override
234214
public void uri(String uri) {
235-
mFormatter.uri(uri);
215+
formatter.uri(uri);
236216
}
237217

238218
@Override
239219
public void feature(Feature feature) {
240-
mFeature = feature;
241-
mFormatter.feature(feature);
220+
currentFeature = feature;
221+
formatter.feature(feature);
242222
}
243223

244224
@Override
245225
public void background(Background background) {
246-
mFormatter.background(background);
226+
formatter.background(background);
247227
}
248228

249229
@Override
250230
public void scenario(Scenario scenario) {
251231
reportLastResult();
252-
mFormatter.scenario(scenario);
232+
formatter.scenario(scenario);
253233
beginScenario(scenario);
254234
}
255235

256236
@Override
257237
public void scenarioOutline(ScenarioOutline scenarioOutline) {
258238
reportLastResult();
259-
mFormatter.scenarioOutline(scenarioOutline);
239+
formatter.scenarioOutline(scenarioOutline);
260240
beginScenario(scenarioOutline);
261241
}
262242

263243
@Override
264244
public void examples(Examples examples) {
265-
mFormatter.examples(examples);
245+
formatter.examples(examples);
266246
}
267247

268248
@Override
269249
public void step(Step step) {
270-
mStep = step;
271-
mFormatter.step(step);
250+
currentStep = step;
251+
formatter.step(step);
272252
}
273253

274254
@Override
275255
public void syntaxError(String state, String event, List<String> legalEvents, String uri, Integer line) {
276-
mFormatter.syntaxError(state, event, legalEvents, uri, line);
256+
formatter.syntaxError(state, event, legalEvents, uri, line);
277257
}
278258

279259
@Override
280260
public void eof() {
281261
reportLastResult();
282-
mFormatter.eof();
262+
formatter.eof();
283263
}
284264

285265
@Override
286266
public void done() {
287-
mFormatter.done();
267+
formatter.done();
288268
}
289269

290270
@Override
291271
public void close() {
292-
mFormatter.close();
272+
formatter.close();
293273
}
294274

295275
@Override
@@ -313,45 +293,45 @@ public void match(Match match) {
313293
}
314294

315295
private void beginScenario(TagStatement scenario) {
316-
String testClass = String.format("%s %s", mFeature.getKeyword(), mFeature.getName());
296+
String testClass = String.format("%s %s", currentFeature.getKeyword(), currentFeature.getName());
317297
String testName = String.format("%s %s", scenario.getKeyword(), scenario.getName());
318-
mTestResult = new Bundle(mResultTemplate);
319-
mTestResult.putString(REPORT_KEY_NAME_CLASS, testClass);
320-
mTestResult.putString(REPORT_KEY_NAME_TEST, testName);
321-
mTestResult.putInt(REPORT_KEY_NUM_CURRENT, ++mScenarioNum);
298+
testResult = new Bundle(resultTemplate);
299+
testResult.putString(REPORT_KEY_NAME_CLASS, testClass);
300+
testResult.putString(REPORT_KEY_NAME_TEST, testName);
301+
testResult.putInt(REPORT_KEY_NUM_CURRENT, ++scenarioCounter);
322302

323-
mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, String.format("\n%s:", testClass));
303+
testResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, String.format("\n%s:", testClass));
324304

325-
sendStatus(REPORT_VALUE_RESULT_START, mTestResult);
326-
mTestResultCode = 0;
305+
sendStatus(REPORT_VALUE_RESULT_START, testResult);
306+
resultCode = 0;
327307
}
328308

329309
@Override
330310
public void result(Result result) {
331311
if (result.getError() != null) {
332312
// If the result contains an error, report a failure.
333-
mTestResult.putString(REPORT_KEY_STACK, result.getErrorMessage());
334-
mTestResultCode = REPORT_VALUE_RESULT_FAILURE;
335-
mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, result.getErrorMessage());
313+
testResult.putString(REPORT_KEY_STACK, result.getErrorMessage());
314+
resultCode = REPORT_VALUE_RESULT_FAILURE;
315+
testResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, result.getErrorMessage());
336316
} else if (result.getStatus().equals("undefined")) {
337317
// There was a missing step definition, report an error.
338318
List<String> snippets = runtime.getSnippets();
339319
String report = String.format("Missing step-definition\n\n%s\nfor step '%s'",
340320
snippets.get(snippets.size() - 1),
341-
mStep.getName());
342-
mTestResult.putString(REPORT_KEY_STACK, report);
343-
mTestResultCode = REPORT_VALUE_RESULT_ERROR;
344-
mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT,
345-
String.format("Missing step-definition: %s", mStep.getName()));
321+
currentStep.getName());
322+
testResult.putString(REPORT_KEY_STACK, report);
323+
resultCode = REPORT_VALUE_RESULT_ERROR;
324+
testResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT,
325+
String.format("Missing step-definition: %s", currentStep.getName()));
346326
}
347327
}
348328

349329
private void reportLastResult() {
350-
if (mScenarioNum != 0) {
351-
if (mTestResultCode == 0) {
352-
mTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, ".");
330+
if (scenarioCounter != 0) {
331+
if (resultCode == 0) {
332+
testResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, ".");
353333
}
354-
sendStatus(mTestResultCode, mTestResult);
334+
sendStatus(resultCode, testResult);
355335
}
356336
}
357337
}

pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@
5050
<slf4j.version>1.7.2</slf4j.version>
5151
<freemarker.version>2.3.19</freemarker.version>
5252
<javax.servlet-api.version>3.0.1</javax.servlet-api.version>
53+
<android-maven-plugin.version>3.6.0</android-maven-plugin.version>
54+
<android.version>2.2.1</android.version>
5355
</properties>
5456
<licenses>
5557
<license>
@@ -349,6 +351,19 @@
349351
<artifactId>cobertura</artifactId>
350352
<version>${cobertura.version}</version>
351353
</dependency>
354+
355+
<dependency>
356+
<groupId>com.google.android</groupId>
357+
<artifactId>android</artifactId>
358+
<version>${android.version}</version>
359+
<scope>provided</scope>
360+
</dependency>
361+
<dependency>
362+
<groupId>com.google.android</groupId>
363+
<artifactId>android-test</artifactId>
364+
<version>${android.version}</version>
365+
<scope>provided</scope>
366+
</dependency>
352367
</dependencies>
353368
</dependencyManagement>
354369

0 commit comments

Comments
 (0)