How to take screenshot at the point where test fail in Espresso?

后端 未结 6 1271
花落未央
花落未央 2021-01-04 05:59

I am looking for a way to take a screenshot of device after test failed and before get closed.

6条回答
  •  心在旅途
    2021-01-04 06:39

    I haven't used screenshots in my Android testing yet, but I know some solutions, which might be useful:

    Spoon

    the best way to do it would be use Emma or Spoon framework.

    Here you would find some useful information how to do it: http://elekslabs.com/2014/05/creating-test-reports-for-android-with-spoon-and-emma.html

    Visit also Spoon's official Github site: https://github.com/square/spoon and its Gradle's plugin: https://github.com/stanfy/spoon-gradle-plugin

    and check related topic: How to get Spoon to take screenshots for Espresso tests?

    screenshot-tests-for-android/

    You can also try this Facebook's library: https://facebook.github.io/screenshot-tests-for-android/

    Robotium's ScreenshotTaker

    As I've already know, with Robotium test framework is possible to create test with screenshots. Check: Correct way to take screenshot with Robotium and Cucumber

    If you don't want to use any library, check source code of Robotium framework class called ScreenshotTaker.java[click on link to see] and write your own ScreenshotTaker class.

    Hope it will help.

提交回复
热议问题