junit4 - android espresso login once before running tests -


i've been trying cover android app tests , have started using espresso recently. pretty impressed far. of app's functionality requires users logged in. , since tests independent, requires registering new user each test. works fine time required each test increases considerably because of this.

i trying find way register user once in class (of tests) , use same user account perform tests in class.

one way have been able have 1 test (@test) method runs other tests in order want. or nothing approach, since gradle cat task outputs results once @ end without providing info intermediate tests may have passed/failed.

i tried @beforeclass approach did not work (no gradle output class had used debug option , seemed took long time before moved on next class of tests).

is there better approach register user once @ start of class , logout once @ end of testing?

any appreciated.

ideally test login/logout functionality in set of tests test different login/logout scenarios, , let other tests focus on other use cases. however, since other scenarios depend on user being logged in, sounds 1 way solve provide mock version of app component handling login. other login dependent tests, inject mock @ start , return mock user credentials rest of app can work with.

here's example dagger, mockito , espresso being used accomplish this: https://engineering.circle.com/instrumentation-testing-with-dagger-mockito-and-espresso/


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -