mardi 6 novembre 2018

Android Testbutler IllegalStateException: ButlerService is not started

I recently added testbutler to my project, and after following their installation guide the test just crashes due to it not being started yet?

build.gradle:

testInstrumentationRunner "com.TestRunner"
...
androidTestImplementation "com.linkedin.testbutler:test-butler-library:1.4.0"

TestRunner:

public class TestRunner extends AndroidJUnitRunner {

@Override
public void onStart() {
    TestButler.setup(InstrumentationRegistry.getTargetContext());
    super.onStart();
}

@Override
public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    TestButler.setup(context);
    return super.newApplication(cl, TestCabinCrewApplication.class.getName(), context);
}

@Override
public void finish(int resultCode, Bundle results) {
    TestButler.teardown(InstrumentationRegistry.getTargetContext());
    super.finish(resultCode, results);
}

}

Testclass:

@RunWith(AndroidJUnit4.class)
@LargeTest
public class ReportSubmittedFragmentTest {

@Before
    public void setup() {          
        TestButler.setWifiState(false);
    }

}

image of error enter image description here

Aucun commentaire:

Enregistrer un commentaire