Creating tests for projects which are targeting several different platforms at once can get quite challenging. Even if the different versions of tested software and devices are designed quite similarly regarding their usage.

I will describe an approach to conveniently tackle such scenarios. are automatically broadcasted to each . Results from each involved platform are grouped together. This is an alternative to driving the and verifications separately for each target platform.

I will give a short example on how test scripts can be developed for performing on several platforms within single test steps. A possible use case would be tests on cloud systems where several different servers and clients may run on different platforms.

The example I’ll give, assumes that all involved AUTs (Applications Under Test) have been started up already, have been registered as ‘Attachable AUTs’ with running squishservers and are now waiting for the test to start. (see: squish documentation)

 

A helper script which Hybrid-Tests can import:

Let’s begin creating a Python class which can store each application’s ‘name’ and ‘applicationContext’ properties. In addition it holds platform-dependent functions and platform-dependent ‘Name Objects’ that may be needed lateron:

 
class ApplicationPlatform:
    nam = ""
    ctx = None
    obj = []
    fnc = []
    def __init__(self,appNam,host="localhost",port=4322):      
        self.ctx = attachToApplication(appNam,host,port)
        self.nam = appNam

 
Also let us define a function which attaches to all tested applications and devices by returning an array of such ‘ApplicationPlatform’ objects, as well as global variables for indexing these:

 
def attachToAllApps():
    return [ ApplicationPlatform("DesktopApp"),
             ApplicationPlatform("IOsDevice"),
             ApplicationPlatform("WinDevice"),
             ApplicationPlatform("AndroidDevice") ]

DesktopApp=0
IOsDevice=1
WinDevice=2
AndroidDevice=3

 
 

Implementing Multi-Platform callable functions:

Now we can implement verification functions which take ‘ApplicationPlatform’ objects as parameter, which are able to perform either:

  • On just one distinct platform alone (if just one platform object passed)
  • Or by doing same actions several times, once per platform (if an array of platforms is passed)

I will show up two example functions:

The first one automates AUTs to create new folders in the cloud’s file system structure:

 
def createNewFolder(app,fldNam,i=0):
    if typeName(app) == "list":
        if i<apps.__len__():
            createNewFolder(app[i],fldNam)
            createNewFolder(app,fldNam,i+1)
    else:
        setApplicationContext(app.ctx)
        mouseClick(names.button_NewFolder) 
        type(names.lineEdit_NewFolder,fldNam)
        mouseClick(names.button_NewFolder_ok)   


 
The second one can verify if some folder may exist within these tree views which our AUTs showing up for accessing files within the cloud:

 
def verifyFolderExists(app,fldNam,i=0):
    if typeName(app) == "list": 
        if i<apps.__len__():
            verifyFolderExists(app[i],fldNam)
            verifyFolderExists(app,fldNam,i+1)
    else:
        setApplicationContext(app.ctx)
        fldObj = names.treeView_folder
        fldObj['name']=fldNam
        if object.exist(fldObj['name']):
            test.passes(app.nam + ": '"+fldNam+"' exists!")
        else:
            test.fail(app.nam + ": '"+fldNam+"' doesn't exist!")   
    return


So now we can implement hybrid tests which do calls to these functions…
 
 

Implementing Hybrid-Tests using the import script:

Our functions can be called either being performed on a single platform, or even as multi-platform call, which will perform on all of our platforms at once:

 
source(findFile("scripts","ApplicationPlatform.py"))

def main(): 
    platforms = attachToAllApps()

    # 1 add a new folder on just the 'Desktop' application:
    createNewFolder(platforms[DesktopApp],"FolderXY")

    # 2 verify if new folder "FolderXY" exists on all devices connected to the cloud:
    verifyFolderExists(platforms,"FolderXY") 

 

Using it in BDD styled Hybrid-Tests also is possible:

Assume following scenario:

Feature: Syncing Documents in a Cloud

Scenario: Synchronize file system between devices

When I create a folder “FolderXY” in the Desktop application.
Then I expect new folder “FolderXY” appears on all devices connected to the cloud.

 

Our step implementations would look like following then:

 
@When("I create a folder “FolderXY” in the Desktop application")
def step(context):
    # lets assign our platform array to the BDD context's userData
    # variable, so it also can be used by other steps which follow:
    context.userData = attachToAllApps()

    # we can call our functions to be performed on just one platform:
    createNewFolder(context.userData[DesktopApp],"FolderXY")
    
@Then("I expect new folder “FolderXY” appears on all devices connected to the cloud.")
def step(context):
    # and we can call being performed on all of the platforms at once 
    verifyFolderExists(context.userData,“FolderXY”)

 
 
 
 
Related links:

https://www.froglogic.com/blog/tip-setting-squish-attach-running-applications-distributed-environment/

https://www.froglogic.com/blog/hybrid-qt-on-android-app-testing/

https://www.froglogic.com/blog/approaches-creating-bdd-scenarios/

 

Attaching to running applications:

https://doc.froglogic.com/squish/latest/rghsa-attach.html#rghsa-attach

 
 



Source link https://www..com/blog/-test-steps-to--target-systems/

LEAVE A REPLY

Please enter your comment!
Please enter your name here