Forum Discussion

678's avatar
678
Regular Contributor
6 years ago

Reusable Functions Framework setup

Can any one share a framework for Reusable Functions Framework setup 

 

currently i have a 

 

Project 

   Library_TestSuite

        Function1_Testcase

        Function2_Testcase

   Actual_Testsuite 

          TestCase1

          TestCase2 

 

 

I need how to call functions when ever i required on any testcase 

 

 

 

Thanks

 

9 Replies

  • groovyguy's avatar
    groovyguy
    Champion Level 1

    Are you meaning that Function1/Function2 are test cases that need to be re-used/re-ran in the actual later test cases? If so, there are two ways I know to handle this. One is groovy being used to run those test cases on demand.  The other is to use a "Run TestCase" test step. That might work.

    It really comes down to what is actually in those Function test cases and what they do, and if they rely on input from the Actual test cases. If that's the case, this'll be more complex.

    • 678's avatar
      678
      Regular Contributor

      Function 1 :  a groovy script to gerenerate randomstringuserid

       

      import java.util.Random;

      Random rand = new Random();
      int num = rand.nextInt(9000) + 9999;

      userid = "test"+num

      context.testRunner.testSuite.setPropertyValue("randomuser", userid)

       

       

       

      Function 2 : a groovy script to generate randomalphanumericpassword

       

      import java.util.Random;

      Random rand = new Random();
      int num = rand.nextInt(9000) + 9999;

      pw = "test"+num

      context.testRunner.testSuite.setPropertyValue("randompassword", pw)

       

       

      Stored these groovy scripts under as Testcases under Library Testsuite 

       

       

       

      • sanj's avatar
        sanj
        Super Contributor

        So for TC you are referencing these groovy scripts?