android - How to get Spoon to take screenshots for Espresso tests? -


i've been trying follow the instructions on getting spoon 1.1.14 take screenshots failing espresso tests.

what's best way configure custom espresso failurehandler?

based on @eric's approach above, , activitytestrule can obtain current test method name , test class name description object when apply() function called. overriding apply function this

public class myactivitytestrule<t extends activity> extends activitytestrule<t> {    @override   public statement apply(statement base, description description) {     string testclassname = description.getclassname();     string testmethodname = description.getmethodname();     context context =  instrumentationregistry.gettargetcontext();     espresso.setfailurehandler(new failurehandler() {       @override public void handle(throwable throwable, matcher<view> matcher) {         spoonscreenshotaction.perform("failure", testclassname, testmethodname);         new defaultfailurehandler(context).handle(throwable, matcher);         }     });     return super.apply(base, description);   }    /* ... other useful things ... */ } 

i able take screenshot correct test method , test class can correctly integrated final spoon test report. , remember use junit4 runner adding

@runwith(androidjunit4.class) 

to test class.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -