Forum Discussion

GenomeTester's avatar
GenomeTester
New Contributor
9 years ago

What persistent data structure to use for storing object variables between app sessions?

My testing scenario: Need to test cached cached objects between two different application sessions App1 and App2. App1 and App2 are two different versions of the same desktop application that retrieve cached data from the same TEMP directory in Windows. 

 

Procedure: Running as one single jscript procedure. 

1) Start App1. 

2) Capture variable object values in TestComplete and store in array variable after converting to string.( I have tried both global array and Project varible type Table).

3) Close App1 using TestComplete.

4) Start App2 in TestComplete ... and capture same data point and store in similar variable type. 

5) Close App2 using TestComplete.

6) Compare the data between the variables for App1 and App2 and report if data is different. 

 

Problem: Closing App1 and App2 causes the object data to be lost in both array type as well as project type variables. Therefore at the compare stage, my test fails as all the variables dont hold anything.

 

Is there a clever solution to this problem??  There has to be a way to store object data in TestComplete once the tested application goes out of scope :( so that it can be used by other methods or scripts at the same/later time. 

 

I have looked into Persistent variables and I am surprised to see that only limited primitive types are allowed. Am I missing something??

 

 

 

2 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Project Variables of Temporary type should work for you.

    If you need to save tested application objects while the tested application is restarted, then you must serialize and deserialize these objects. This is because TestComplete does not store object copy (which is senseless) but keeps a reference to it and the tested application deletes all its objects when closed.

    Anyway, objects itself cannot be compared, only their serialized representation can be.

    • GenomeTester's avatar
      GenomeTester
      New Contributor

      Hi,

       

      I was able to solve my problem without the need to serialize and deserialize objects. Also I did not need to use Project Variable of Temporary type either. 

       

      I used the aqString.Concat() function to append a dummy string to object.ToString() and was able to save it to my global array variable. I think this somehow forced TestComplete to re allocate the reference to actually a string variable and pass by value. Now when the tested application is restarted, I only needed to account for the dummy string before my comparison and everything worked as expected. 

       

      Thanks!