Having trouble automating Android testing with Appium
I'm trying to automate Android testing using Appium. What I want to do is like:
My Test Suite: Test case 1: Starting from Activity A Do something Test case 2: Starting from Activity A Do something
The problem is that if you go to another Activity while performing test case 1, you need to somehow navigate back to the first Activity.
At first I've tried manually going back.
My Test Suite: Test case 1: Starting from Activity A Do something (<- this takes you to Activity B) Navigate back to Activity A Test case 2: Starting from Activity A Do something
But if the case fails on the step
Navigate back to Activity Awon't execute. What would be the best practice?
- Separate cases into suites?
Navigate back to Activity Aon
- Or anything better?
This won't make any significant differences, but I'm using Appium + Jest + WebdriverIO.
Make your tests independent of each other.
Jest has the concept of beforeEach and afterEach functions. Use these to start and quit your Appium session for each test.
When the app opens for each test it will be in the same place, and you can work forward from there.
It adds a little overhead to each test, but it will let you avoid major headaches trying to write 'recovery' code in case something unexpected happens and a test doesn't end where you need to.
If you plan to use a device farm (e.g. Browserstack) at any point, there may be issues with running your tests on the same session, too. It probably won't record session videos correctly (one long video instead of individual test cases) and you will probably hit a session timeout if your (single session) test goes over 15-30 minutes.