I am getting the error while capturing the screenshots using the fastlane
Code in my androidTest
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.tcc.gstknowledge", appContext.getPackageName());
}
@ClassRule
public static final LocaleTestRule localeTestRule = new LocaleTestRule();
@Rule
public ActivityTestRule<MainActivity> activityRule = new ActivityTestRule<>(MainActivity.class);
@Test
public void testTakeScreenshot() {
Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
Screengrab.screenshot("before_button_click");
// Your custom onView...
onView(withId(R.id.activity_btn1)).perform(click());
Screengrab.screenshot("after_button_click");
}
}
I have a lane file with this code.
lane :screenshots do
capture_android_screenshots
#upload_to_play_store
end
desc "assembleDebug assembleAndroidTest"
lane :assembleScreengrab do
gradle(task: "assembleDebug assembleAndroidTest")
end
I am trying to execute the following commands in the terminal inside my project folder.
fastlane assembleScreengrab
for the creating the debug build and test debug build.fastlane screenshots
for the capturing the Screenshots.But when i am trying to capture screenshot by executing the fastlane screenshots
it will give me the following error of the
INSTRUMENTATION_STATUS_CODE: -1
Detailed Error Screenshot :-
I got the error and the solution is add this line in your build.gradle file i have an old project so it will not added in that particular project but now days it will come by default when we are creating the android project.
defaultConfig {
....
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
....
}