Skip to content

Commit

Permalink
Merge pull request #14 from lifedemons/feature/2/android_orchestrator…
Browse files Browse the repository at this point in the history
…_integration

Introduced CucumberJUnitRunner - a bridge between Cucumber Features and Android Test Orchestrator
  • Loading branch information
lsuski authored Feb 27, 2019
2 parents 3772b67 + a42bd59 commit 15cbf8f
Show file tree
Hide file tree
Showing 21 changed files with 505 additions and 1,521 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'io.codearte.nexus-staging'


ext {
targetSdkVersion = 27
targetSdkVersion = 28
buildToolsVersion = '28.0.3'
minSdkVersion = '14'

Expand Down
4 changes: 3 additions & 1 deletion cucumber-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ configurations.all {

dependencies {
api "io.cucumber:cucumber-java:$cucumber_javaVersion"
testImplementation 'junit:junit:4.12'
api "io.cucumber:cucumber-junit:$cucumber_javaVersion"
api 'junit:junit:4.12'
api "androidx.test:runner:1.1.1"
testImplementation "org.robolectric:robolectric:4.1"
testImplementation "org.powermock:powermock-api-mockito2:2.0.0"
testImplementation "org.powermock:powermock-module-junit4:2.0.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package cucumber.api.android;

import android.os.Bundle;
import androidx.test.runner.AndroidJUnitRunner;
import cucumber.runtime.android.CucumberJUnitRunnerBuilder;

/**
* {@link AndroidJUnitRunner} for cucumber tests. It supports running tests from Android Tests Orchestrator
*/
public class CucumberAndroidJUnitRunner extends AndroidJUnitRunner {

public static final String CUCUMBER_ANDROID_TEST_CLASS = "cucumberAndroidTestClass";
private static final String ARGUMENT_ORCHESTRATOR_RUNNER_BUILDER = "runnerBuilder";
private static final String ARGUMENT_ORCHESTRATOR_CLASS = "class";
private Bundle arguments;

@Override
public void onCreate(final Bundle bundle) {
bundle.putString(ARGUMENT_ORCHESTRATOR_RUNNER_BUILDER, CucumberJUnitRunnerBuilder.class.getName());

String testClass = bundle.getString(ARGUMENT_ORCHESTRATOR_CLASS);
if (testClass != null && !testClass.isEmpty()){
//if this runner is executed for single class (e.g. from orchestrator or spoon), we set
//special option to let CucumberJUnitRunner handle this
bundle.putString(CUCUMBER_ANDROID_TEST_CLASS, testClass);
}
//there is no need to scan all classes - we can fake this execution to be for single class
//because we delegate test execution to CucumberJUnitRunner
bundle.putString(ARGUMENT_ORCHESTRATOR_CLASS, CucumberJUnitRunnerBuilder.class.getName());

arguments = bundle;

super.onCreate(bundle);
}

public Bundle getArguments() {
return arguments;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,12 @@ private void addResourceRecursive(final List<Resource> resources,
return;
}

for (final String name : assetManager.list(schemeSpecificPart)) {
String subPath = String.format(RESOURCE_PATH_FORMAT, schemeSpecificPart, name);
addResourceRecursive(resources, assetManager, URI.create(subPath), suffix);
String[] list = assetManager.list(schemeSpecificPart);
if (list != null) {
for (String name : list) {
String subPath = String.format(RESOURCE_PATH_FORMAT, path.toString(), name);
addResourceRecursive(resources, assetManager, URI.create(subPath), suffix);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void requestDump(final Bundle bundle) {
}

private void reportError(final Bundle results, final Exception e) {
Log.e(CucumberExecutor.TAG, LOG_ERROR_OUTPUT, e);
Log.e(CucumberJUnitRunner.TAG, LOG_ERROR_OUTPUT, e);
appendNewLineToResultStream(results, RESULT_STREAM_ERROR_OUTPUT);
}

Expand Down
Loading

0 comments on commit 15cbf8f

Please sign in to comment.