简体   繁体   中英

Applying JUnit Rules to UiAutomator tests

I am currently working on some UiAutomator testcases which will run in a huge test-system. I must do some Ui-walking before each testcase starts. In what ways is this possible? I have investigated JUnit Rules, but it seems like those are meant for static usage(?), which is n/a to my usecase. My pseudo-code of what I want to accomplish follows below.

public class TestCases extends UiAutomator{ 
@Before
public void setCorrectUi() { getUiDevice().makeMeLaugh();}
@Test
public void setWallpaper() { getUiDevice().makeMeCry();  }
}

Are there any JUnit Rules which can be applied after instantiation of testclasses? Are there any cleaner more appropriate ways of accomplishing this? I know I could put my pseudo @Before in a testcase, but since that is not inside the testscope I don't want to do this.

Grateful for answers! :)

Android Testcase uses Junit3, you are provided with setup and teardown methods to accomplish this. You can refer this docs

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM