Print Page | Close Window

Donate a user defined function to this topic !!!

Printed From: One Stop Testing
Category: Testing Tools @ OneStopTesting
Forum Name: SilkTest @ OneStopTesting
Forum Discription: SilkTest is an automation tool for testing the functionality of enterprise applications in most versions of Windows, Sun Solaris 9 & 10, and Red Hat Enterprise Linux WS 2.1 & 3.0.
URL: http://forum.onestoptesting.com/forum_posts.asp?TID=2794
Printed Date: 17Nov2024 at 6:48am


Topic: Donate a user defined function to this topic !!!
Posted By: tanushree
Subject: Donate a user defined function to this topic !!!
Date Posted: 12Oct2007 at 5:25am
Here's a variation on Verify that strongly prefer over the original.
code:
[+] VerifyAndContinue( anytype pInActual ,anytype pInExpected ,string pDesc )
[-] do
[ ] Verify( pInActual ,pInExpected ,pDesc )
[ ] print( "VERIFY "+ pDesc+ " PASSED." )
[ ]
[-] except
[ ] LogVerifyError( pInActual ,pInExpected ,pDesc )
[ ]
[ ]
[+] // NOTES for VerifyAndContinue:
[ ] // Objections to Verify:
[ ] // 1: On PASS ,nothing is written to the .res.
[ ] // 2: On FAIL ,the testcase is terminated immediately.
[ ]
[ ] // Both these objections are overcome by VerfiyAndContinue.
[ ] // 1: On PASS ,"Verify "+ pDesc+ " passed." is written to the .res.
[ ] // 2: On FAIL ,except path prevents termination and LogVerifyError is executed.
[ ]
[ ] // Otherwise Verify behaves nicely.
[ ] // In particular ,it can handle lists of different lengths.
[ ]



Replies:
Posted By: ram7vasu
Date Posted: 08Jan2008 at 1:49am

Example1:

 STRING s = "now is the time for all the good men"

        //search forward to find first occurrence of "the"

        Print (StrPos ("the", s)) // prints: 8

        //search backward to find second occurrence of "the"

        Print (StrPos ("the", s, TRUE)) // prints: 25

        Print (StrPos ("x", s))  // prints: 0

 

RandPick function

Returns a random item from a list.Smile

 

Syntax

aElem = RandPick (lList)

 

Notes

 RandPick returns a random item from laList. The item can have any data type.

 

Example2:

testcase RandPickExample ()

           LIST OF STRING lsItems

           STRING sRandomItem

           lsItems = {...}

              "Clam Chowder"

              "Fried Chicken"

              "Lobster"

              "Green Eggs and Ham"

           sRandomItem = RandPick (lsItems)

           Print ("The special of the day is {sRandomItem}.")



-------------
RAM SAKSOFT


Posted By: ram7vasu
Date Posted: 08Jan2008 at 2:13am

In how many ways we can perform datadriven test in...  

In silk test we can parametrize through
1. Flat file by using file handling concept
            HFILE f1
            f1 = FileOpen(filepath,FM_READ)
            string str

            filereadline(f1, str)
         this "str" parameter can be passed to the scripting for parametrization
            fileclose(f1)
2. Using external database and establishing connection through scripting
          HANDLE h1
          HANDLE h2
          h1 = db_connect("DSN = x.mdb")
          h2 = db_executesql(h1,"Select * from table1")
          string i
          while(db_fetchnext(h2,i)
           this "i" parameter can be used for data driven
          db_finishsql(h2)
          db_disconnect(h1)
3. List of function
          List of string a = {....}
          "xyx"
         " 123"
         "@#$"
       for each x in a
         this "x" parameter can be used for data driven

Smile

-------------
RAM SAKSOFT


Posted By: ram7vasu
Date Posted: 08Jan2008 at 2:17am

[-] testcase DBTester () appstate none

            [ ]

            [ ] // Use the QA DBTester functions to access the GMO database

            [ ] // Print GMO's customer list

            [ ]

            [ ] STRING custnum, lname, fname

            [ ] HDATABASE hdbc

            [ ] HSQL hstmnt

            [ ]

            [ ] // connect to the GMO Microsoft Access database, gmt.db

            [ ] hdbc = DB_Connect ("dsn=gmovb")

            [ ]

            [ ] // retrieve everything from the customer table

            [ ] hstmnt = DB_ExecuteSql (hdbc, "SELECT * FROM cidb ORDER BY last_name")

            [ ]

            [ ] // process the retrieved data and print customer names

            [ ] print ("GMO Customer List:")

            [ ] print ()

            [-] while (DB_FetchNext (hstmnt, custnum, fname, lname))

                        [ ] print ("{lname}, {fname}")

            [ ]

            [ ] // release resources

            [ ] DB_FinishSql (hstmnt)

            [ ]

            [ ] // disconnect from the GMO database

            [ ] DB_Disconnect (hdbc)  Smile



-------------
RAM SAKSOFT



Print Page | Close Window