4
4
import android .app .Instrumentation ;
5
5
import android .content .Context ;
6
6
import android .os .Bundle ;
7
+ import android .os .Debug ;
7
8
import android .os .Looper ;
8
9
import android .util .Log ;
9
10
import cucumber .api .CucumberOptions ;
@@ -37,6 +38,7 @@ public class CucumberInstrumentation extends Instrumentation {
37
38
private ResourceLoader resourceLoader ;
38
39
private ClassLoader classLoader ;
39
40
private Runtime runtime ;
41
+ private boolean debug ;
40
42
41
43
@ Override
42
44
public void onCreate (Bundle arguments ) {
@@ -45,6 +47,9 @@ public void onCreate(Bundle arguments) {
45
47
if (arguments == null ) {
46
48
throw new CucumberException ("No arguments" );
47
49
}
50
+
51
+ debug = getBooleanArgument (arguments , "debug" );
52
+
48
53
Context context = getContext ();
49
54
classLoader = context .getClassLoader ();
50
55
@@ -88,6 +93,10 @@ private DexFile newDexFile(String apkPath) {
88
93
@ Override
89
94
public void onStart () {
90
95
Looper .prepare ();
96
+
97
+ if (debug ) {
98
+ Debug .waitForDebugger ();
99
+ }
91
100
92
101
final List <CucumberFeature > cucumberFeatures = runtimeOptions .cucumberFeatures (resourceLoader );
93
102
final int numberOfTests = TestCaseCounter .countTestCasesOf (cucumberFeatures );
@@ -119,4 +128,9 @@ private void printSummary() {
119
128
Log .w (TAG , s );
120
129
}
121
130
}
131
+
132
+ private boolean getBooleanArgument (Bundle arguments , String tag ) {
133
+ String tagString = arguments .getString (tag );
134
+ return tagString != null && Boolean .parseBoolean (tagString );
135
+ }
122
136
}
0 commit comments