Skip to content

Commit e5e356f

Browse files
committed
Merge pull request cucumber#613 from fluxtah/master
Added debug wait to make sure eclipse attaches debugger appropriately
2 parents 7ce7a5c + 0b03558 commit e5e356f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.app.Instrumentation;
55
import android.content.Context;
66
import android.os.Bundle;
7+
import android.os.Debug;
78
import android.os.Looper;
89
import android.util.Log;
910
import cucumber.api.CucumberOptions;
@@ -37,6 +38,7 @@ public class CucumberInstrumentation extends Instrumentation {
3738
private ResourceLoader resourceLoader;
3839
private ClassLoader classLoader;
3940
private Runtime runtime;
41+
private boolean debug;
4042

4143
@Override
4244
public void onCreate(Bundle arguments) {
@@ -45,6 +47,9 @@ public void onCreate(Bundle arguments) {
4547
if (arguments == null) {
4648
throw new CucumberException("No arguments");
4749
}
50+
51+
debug = getBooleanArgument(arguments, "debug");
52+
4853
Context context = getContext();
4954
classLoader = context.getClassLoader();
5055

@@ -88,6 +93,10 @@ private DexFile newDexFile(String apkPath) {
8893
@Override
8994
public void onStart() {
9095
Looper.prepare();
96+
97+
if (debug) {
98+
Debug.waitForDebugger();
99+
}
91100

92101
final List<CucumberFeature> cucumberFeatures = runtimeOptions.cucumberFeatures(resourceLoader);
93102
final int numberOfTests = TestCaseCounter.countTestCasesOf(cucumberFeatures);
@@ -119,4 +128,9 @@ private void printSummary() {
119128
Log.w(TAG, s);
120129
}
121130
}
131+
132+
private boolean getBooleanArgument(Bundle arguments, String tag) {
133+
String tagString = arguments.getString(tag);
134+
return tagString != null && Boolean.parseBoolean(tagString);
135+
}
122136
}

0 commit comments

Comments
 (0)