简体   繁体   中英

How do you functional test an Android application fully using Robotium

我正在开发一个Android应用程序,其工作流分散在许多活动中。我想使用Robotium测试某些特定用户操作的每个活动。我应该如何使用Robotium来实现此目的?我应该为所有活动创建一个测试类还是应该为不同的活动创建不同的测试类。我尝试了后一种方法,但是robotium同时运行所有测试类,破坏了应用程序流程。我希望测试流程与应用程序流程相同。

Your question is very vague but here is my suggestion.

Test cases should be very small, you preferably want your test to only test one thing so that you know exactly what went wrong if it fails. Unfortunately this is an idealist view and unlikely to be the case especially with fairly slow UI based tests.

So here is what i recommend you do, I would create test classes not based on the activity they test but based around the functionality they are testing (this is probably pretty close to the activities though, eg login page) and then have a method in each that tests each requirement (eg failed login, succesfull login etc) but make sure that each test takes you back to a common starting point, in this case I would suggest the login page, that way your tests can run in any order and each one tests each individual test flow.

You can try to rename your test method to have a flow identified by alphabetical order of the names.

For example if you have a login and then a checkin you could call the first test method test_app_001_login and the second test_app_002_checkin

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