Different capabilities for different scenarios

i am solving it with testNG by specifying parameter like: fullReset, fastReset and nothing.
in “beforeMethod” i am reading this parameter and specify how driver to start:

        if (devicePlatform.contains("fullReset")) { // uninstall and install client
            System.out.println("  Driver DO FULL-RESET");
            capabilities.setCapability(MobileCapabilityType.FULL_RESET, true);
            capabilities.setCapability(MobileCapabilityType.NO_RESET, false);
        } else if (devicePlatform.contains("fastReset")) { // clears cache and settings without reinstall for Android / reinstall app for iOS
            System.out.println("  Driver DO FAST-RESET");
            capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
            capabilities.setCapability(MobileCapabilityType.NO_RESET, false);
        } else { // just start client
            System.out.println("  Driver DO NORMAL start"); 
            capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
            capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
        }

normally i do ONE test with fullReset to install new version, min possible number of tests with fastReset (cause it is slowing start) and all other tests with normal start.

in testNG it is look like:

<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="BVT_Android">
    <test name="doReinstall" preserve-order="true">
        <parameter name="devicePlatform" value="android fullReset"/>
        <parameter name="deviceName" value="loc_Sony_Z1"/>
        <classes>
            <class name="com.xxxx.tests.android.test_1">
                <methods>
                    <include name="test_reinstall"></include>
                </methods>
            </class>
        </classes>
    </test>
   <test name="doReset" preserve-order="true">
        <parameter name="devicePlatform" value="android fastReset"/>
        <parameter name="deviceName" value="loc_Sony_Z1"/>
        <classes>
            <class name="com.xxxx.tests.android.test_2">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            <class name="com.xxxx.tests.android.test_3">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            ....
        </classes>
    </test>
   <test name="normalStart" preserve-order="true">
        <parameter name="devicePlatform" value="android"/>
        <parameter name="deviceName" value="loc_Sony_Z1"/>
        <classes>
            <class name="com.xxxx.tests.android.test_4">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            <class name="com.xxxx.tests.android.test_5">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            ....
        </classes>
    </test>
</suite>
1 Like