android - Espresso - Testing non Activity class with CountingIdlingResource -


i'm trying test class using countingidlingresource. why when run test1() method, test falls assertheresomething() line before task has been done?

please me.

public myclass {     public countingidlingresource midlingresource;      @visiblefortesting     @nonnull     public countingidlingresource getidlingresource() {         if (midlingresource == null) {             midlingresource = new countingidlingresource("worker");         }         return midlingresource;     }      executorservice executor = executors.newsinglethreadexecutor();      public void makeasynctask(){         midlingresource.increment();         executor.submit(new runnable() {             @override             public void run() {                 dotask();                 midlingresource.decrement();             }         });     } }   @runwith(androidjunit4.class) public class testclass  {     myclass myclass = new myclass());     @before     public void dobefore() throws exception {         espresso.registeridlingresources(myclass.getidlingresource());     }      @test     public void test1(){         myclass.makeasynctask();         assertheresomething(); // runs before task has been done?     } } 


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -