I use Appium for testing Android device in C#.
Every time i run a test case, i need to go to Main screen and then begin the use case. This can be achieved in two ways, using: LaunchApp and StartActivity function.
As far as i believe, LaunchApp launches app again, that is killing the running app and start the app from the beginning. However i will end up in startup activity. This will free up memory space, so app will not go into stress or out of memory issues. StartActivity will not kill the App, but switch to particular activity. Which will be same as real case testing.
Is my above statement true? or what is the exact difference between the both?
In general you got it right, but it worth to add more context here.
How it works:
launchApp()
by default does the following:
appWaitPackage
, appWaitActivity
)startActivity
does the following:
Real life examples, e.g. app that has LoginActivity -> NavigationActivity -> WhateverActivity
flow:
a) launchApp()
will clean the app and move you back to LoginActivity
b) startActivity(NavigationActivity)
will just launch NavigationActivity
, so you don't have to login to the app.
a) launchApp()
will be same as in Q1
b) startActivity(NavigationActivity) will fail with Incorrect package and activity
as app flow does not allow it.
I'm using startActivity
before each test to get to start point
, that helps to speedup tests suite by avoiding app reinstall and relogin multiple times.