Open Ankhwatcher opened 6 years ago
I have a run listener that cleans them before each run.
You can add it by passing the listener
instrumentation argument.
Example : --instrumentation-arguments listener my.package.ClearSpoonScreenshotsRunListener
import android.os.Environment
import android.support.test.internal.runner.listener.InstrumentationRunListener
import android.support.test.runner.permission.PermissionRequester
import android.util.Log
import org.junit.runner.Description
class ClearSpoonScreenshotsRunListener : InstrumentationRunListener() {
override fun testRunStarted(description: Description?) {
super.testRunStarted(description)
clearSpoonScreenshots()
}
private val TAG = "ClearSpoonScreenshotsRunListener"
fun clearSpoonScreenshots() {
val requester = PermissionRequester()
requester.addPermissions(
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.Manifest.permission.READ_EXTERNAL_STORAGE)
requester.requestPermissions()
val root = Environment.getExternalStoragePublicDirectory("app_spoon-screenshots")
val deleteRecursively = root.deleteRecursively()
val result = if (deleteRecursively) "success" else "failure"
Log.i(TAG, "clearing screenshots from folder ${root.absolutePath} $result")
}
}
We're doing a similar thing from Gradle after the testComposerDebug
task (we're using the third party Gradle plugin).
I also think this should be done by Composer after successfully pulling the files. Maybe having some option to skip it, since it's helpful keeping the files for debugging purposes.
its should be pretty easy to follow with an adb command to delete the file after they pull it. i do exactly that when pulling bitmaps in kontrast. https://github.com/trevjonez/Kontrast/blob/master/plugin/src/main/kotlin/com/trevjonez/kontrast/task/RenderOnDeviceTask.kt#L139
Hey folks,
I'm using Composer with Spoon 2.0 for screenshots. (If there is a native way to take screenshots in Composer or a better recommended tool please let me know!)
My screenshots are being taken and downloaded and added to the report okay, but all previous screenshots from all previous runs are also in the report.
It doesn't matter if I run composer as a clean or not.
Any help or guidance here would be greatly appreciated.
Thanks, ANkh