Skip to content

simonpoole/ScreenshotRule

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ScreenshotRule

Junit rule to generate screenshots when running tests with Spoon.

This replaces the Spoon "SpoonRule.screenshot". As the Spoon implementation only renders the top level "DecorView" it will not render any dialogs that create additional "Windows", while relying on reflection and due to that by definition a hack, this modified library does provide something closer to an actual screenshot. Using the hack can be avoided by using UiAutomation.takeScreenshot() with saveScreenshot.

The original code can be found here https://github.com/square/spoon/tree/master/spoon-client

Usage

    @Rule
    public ScreenshotRule screenshotRule = new ScreenshotRule();
    ...
    screenshotRule.screenshot(activity, "tag");

or

    @Rule
    public ScreenshotRule screenshotRule = new ScreenshotRule();
    ...
    screenshotRule.saveScreenshot(activity, "tag", instrumentation.getUiAutomation().takeScreenshot());

Including in your project

Add the following to your build.gradle file(s):

repositories {
    maven {
        mavenCentral()
    }
}
dependencies {
    androidTestImplementation "com.squareup.spoon:spoon-client:2.0.0-SNAPSHOT"
    androidTestImplementation 'ch.poole.android:ScreenshotRule:0.2.0'
}

About

Junit rule to generate screenshots when running tests with Spoon

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages