// Path: app/src/androidTest/java/com/tobi/movies/TestMovieApplication.java
// public class TestMovieApplication extends MovieApplication {
// 
//     @Override
//     protected ApplicationComponent applicationComponent() {
//         return DaggerTestApplicationComponent.create();
//     }
// 
//     @Override
//     protected PopularMoviesComponent popularMoviesComponent(ApplicationComponent applicationComponent) {
//         return DaggerTestPopularMoviesComponent.builder()
//                 .testApplicationComponent((TestApplicationComponent) applicationComponent)
//                 .build();
//     }
// 
//     @Override
//     protected MovieDetailsComponent movieDetailsComponent(ApplicationComponent applicationComponent) {
//         return DaggerTestMovieDetailsComponent.builder()
//                 .testApplicationComponent((TestApplicationComponent) applicationComponent)
//                 .build();
//     }
// }


import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.support.test.runner.AndroidJUnitRunner;
import com.tobi.movies.BuildConfig;
import com.tobi.movies.TestMovieApplication;
import cucumber.api.android.CucumberInstrumentationCore;
    public void onCreate(final Bundle bundle) {
        String tags = BuildConfig.TEST_TAGS;
        if (!tags.isEmpty()) {
            String tagsKey = tags.replaceAll("\\s", "");
            bundle.putString(CUCUMBER_TAGS_KEY, tagsKey);
        }

        String scenario = BuildConfig.TEST_SCENARIO;
        if (!scenario.isEmpty()) {
            scenario = scenario.replaceAll(" ", "\\\\s");
            bundle.putString(CUCUMBER_SCENARIO_KEY, scenario);
        }

        String feature = BuildConfig.TEST_FEATURE;
        if (!feature.isEmpty()) {
            bundle.putString(CUCUMBER_FEATURE_KEY, feature);
        }

        instrumentationCore.create(bundle);
        super.onCreate(bundle);
    }

    @Override
    public void onStart() {
        waitForIdleSync();
        instrumentationCore.start();
    }

    @Override
    public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
// Path: app/src/androidTest/java/com/tobi/movies/TestMovieApplication.java
// public class TestMovieApplication extends MovieApplication {
// 
//     @Override
//     protected ApplicationComponent applicationComponent() {
//         return DaggerTestApplicationComponent.create();
//     }
// 
//     @Override
//     protected PopularMoviesComponent popularMoviesComponent(ApplicationComponent applicationComponent) {
//         return DaggerTestPopularMoviesComponent.builder()
//                 .testApplicationComponent((TestApplicationComponent) applicationComponent)
//                 .build();
//     }
// 
//     @Override
//     protected MovieDetailsComponent movieDetailsComponent(ApplicationComponent applicationComponent) {
//         return DaggerTestMovieDetailsComponent.builder()
//                 .testApplicationComponent((TestApplicationComponent) applicationComponent)
//                 .build();
//     }
// }


// Path: app/src/androidTest/java/com/tobi/movies/utils/CucumberInstrumentation.java
import android.app.Application;
import android.content.Context;
import android.os.Bundle;
import android.support.test.runner.AndroidJUnitRunner;
import com.tobi.movies.BuildConfig;
import com.tobi.movies.TestMovieApplication;
import cucumber.api.android.CucumberInstrumentationCore;

    public void onCreate(final Bundle bundle) {
        String tags = BuildConfig.TEST_TAGS;
        if (!tags.isEmpty()) {
            String tagsKey = tags.replaceAll("\\s", "");
            bundle.putString(CUCUMBER_TAGS_KEY, tagsKey);
        }

        String scenario = BuildConfig.TEST_SCENARIO;
        if (!scenario.isEmpty()) {
            scenario = scenario.replaceAll(" ", "\\\\s");
            bundle.putString(CUCUMBER_SCENARIO_KEY, scenario);
        }

        String feature = BuildConfig.TEST_FEATURE;
        if (!feature.isEmpty()) {
            bundle.putString(CUCUMBER_FEATURE_KEY, feature);
        }

        instrumentationCore.create(bundle);
        super.onCreate(bundle);
    }

    @Override
    public void onStart() {
        waitForIdleSync();
        instrumentationCore.start();
    }

    @Override
    public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
        String testAppClassName = TestMovieApplication.class.getCanonicalName();