Forum Discussion

vatbub's avatar
vatbub
Contributor
9 years ago
Solved

Declare tests that depend on other tests

Hi there,

We use TestComplete for mobile testing. For our app, we've set up several tests. The thing is, that these tests depend on each other.

E. g., we have test A that launches the app and checks if it launched. Then we have another test B that tests the apps functionality.

 

How can I ensure that when calling test B, test A is executed first? I know that I could call test A maually but we have way more than two tests and then we would need to set up something like an xml-Dependency tree and that would be quite a hard work.

That's why I wanted to ask if there is a simple and intuitive way to declare those dependencies in TestComplete.

Thanks,

vat

  • What we have done in a similar case is create a wrapper test that does nothing but call the other tests in the order we want them.  It makes the log file a little longer but it's a good way to control the test flow.

     

    The other thing you could do is put a call to test A inside test B.  Our "pick the option from the menu" test is called inside every test that needs it.  

5 Replies

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    What we have done in a similar case is create a wrapper test that does nothing but call the other tests in the order we want them.  It makes the log file a little longer but it's a good way to control the test flow.

     

    The other thing you could do is put a call to test A inside test B.  Our "pick the option from the menu" test is called inside every test that needs it.  

  • What scripting language are you using? Isn't this just a function call?

    • Ravik's avatar
      Ravik
      Super Contributor

      You can also do,

       

      Ues Functions (Functions return values)

       

      Create your Test A in a function and return value from it when all the statements are execute successfuly. If function return your expected value then start your Test B.  like --

       

      Function fun_TestA()

      ----------------------------------

      -----------------

       

      IF HomePage(First Page) Then

        fun_TestA=True

       

      Else

       

        fun_TestA=False

       

      End Function

       

      Now check in Test B

       

      Function fun_TestB

       

      a = fun_TestA

      IF a = True Then

      ----------TEST B Statements

      ---------------

      ---------------

      Else

       

      Message ("Test A Fail")

      End If

       

      End Function

       

       

      this may help you.

       

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi Vat,

     

    Maybe I missed something in your question...

    For the scheduled batch test runs:

    Have you considered to organize your tests using the Test Items tree (https://support.smartbear.com/viewarticle/71373/) ?

    Test Items tree makes it possible for you to specify if the test run should be stopped at all if some test fails, or ignore the problem and continue or stop execution of dependent child tests and continue from the same level.

    Note, that as some test can fail and stop, this can leave the tested application in an intermediate state. So my opinion is that it is a good idea to make a test to do some initial actions to ensure that the tested application can be controlled. (For example, do a loop until the main tested application window can be activated and close all windows (with the help of OnUnexpectedWindow event handler) that prevent this.) Obviously, depending on how modular your tests are and how they are implemented, the above action may not be required for all tests, but may be useful for some top-level ones to improve tests reliability.

    The known problem with Test Items is the impossibility to specify in the TestComplete command line what test items must be executed. But the script provided by SmartBear at https://support.smartbear.com/viewarticle/54655/ helps to resolve this.

    • vatbub's avatar
      vatbub
      Contributor

      Hey guys,

      thanks for your help.

      We use JavaScript for scripting.

      What we wanted to achieve was something like this:

      Suppose test A needs to be executed before Test B for Test B to work. So if I launch Test A and then Test B, everything is fine but if I forget to launch Test A, TestComplete should launch it automatically when I launch Test B.

       

      Now, we've decided to go for a completely different solution:

      As we use an Excel workbook to specify which tests to be executed in the nightly tests, we use conditional formatting in Excel to warn us in case we do a mistake.

      Thanks anyway,

      vat