JoaquimLey / transport-eta

Twitch streamed 🎥playground repo, README speaks to you.
https://medium.com/@JoaquimLey/android-architecture-components-now-with-100-more-mvvm-11629a630125
Apache License 2.0
224 stars 45 forks source link

Automated Screenshots #40

Open JoaquimLey opened 6 years ago

JoaquimLey commented 6 years ago

Add a task for automated screenshots

Context

References

Test class example:

@RunWith(AndroidJUnit4.class)
public class FirstScreenShootTest {

    @ClassRule
    public static final LocaleTestRule localeTestRule = new LocaleTestRule();

    @Rule
    public ActivityTestRule<SomeActivity> activityRule = new ActivityTestRule<>(SomeActivity.class);

    @BeforeClass
    public static void setupClass() {
        Screengrab.setDefaultScreenshotStrategy(new UiAutomatorScreenshotStrategy());
    }

    @AfterClass
    public static void tearDownClass() throws Exception {
                //       Code executed after the last test method
    }

    @Before
    public void setup() {

    }

    @After
    public void tearDown() {

    }

    @Test
    public void testTakeScreenshot() {
        Screengrab.screenshot("file_name");

        onView(withId(R.id.fab)).perform(click());

        Screengrab.screenshot("after_click_screen_shot_file_name");
    }
}