SPONSORS:






User Tag List

Results 1 to 6 of 6
  1. #1
    Member
    Join Date
    Mar 2000
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I create SilkTest custom functions?

    I am fairly new to the 4Test language, but I understand programming concepts. I was wondering if anyone could tell me if there was a way to create custom functions so that i can reuse code instead of rewriting it.

    Also, is there any way that I could create a global variable? Someone mentioned that I should write the contents of the variable to a file and then read it out each time... This doesn't seem right...
    The reasoning behind it was that each test case run re-initializes the environment.

    Any assistance will be appreciated.

    Thanks,
    Peter

  2. #2
    Junior Member
    Join Date
    Oct 2000
    Location
    Halifax, NS, Canada
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How can I create SilkTest custom functions?

    How much programming have you done in the past? I find 4Test to be very similar to C++ (which I used throughout university).

    How are you looking to implement your tests? Are they all in a single test file?

    If that's the case you can use the same method that I've been using... declare seperate functions for pieces of the code that you want to use over and over again.

    For example.. I have a single test file called ABC.t. Inside this file are all the test cases that I want to use along with a few generic functions that can be called.

    ABC.t

    //function to clear the screen
    clear_screen ()
    //funtion to log in
    login ()

    //testcases
    testcase Check_date ()

    *declare variables and stuff here*
    *begin scripting here*
    clear_screen ()
    login ()
    *continue script*

    testcase Check_time ()
    *declare variables and stuff here*
    *begin scripting here*
    clear_screen ()
    login ()
    *continue script*

    The same 2 functions are used several times...

    the same is true for global variables If they're being used by all testcases in the same file.

    at the top of your test file declare your varibles:

    const STRING date1 = 00/11/15
    const INTEGER cost = 2500

    and they can be referenced later on by any script as normal.. if you need each script to be able to modify these values you'll need to find another way to use global variables (cant remember how at the moment)

    If you're using several different files to hold your test cases you could always create a seperate file to hold all the variables and functions that you need and then "include" it in whatever testcase file needs to reference them.

    I've only been using SilkTest for a few weeks so there are probably more sophisticated ways to implement these ideas, but at least this should get you started.

    Hope this helps.
    Martin H

    [This message has been edited by mhemmings (edited 11-15-2000).]

  3. #3
    Junior Member
    Join Date
    Apr 2000
    Location
    Chelmsford, MA, USA
    Posts
    9
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How can I create SilkTest custom functions?

    I found that the easiest way is to collect my custom functions in my .inc file.

  4. #4
    Junior Member
    Join Date
    Aug 2000
    Posts
    22
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How can I create SilkTest custom functions?

    Check out the thread "Global variables and the Invoke method"

  5. #5
    Member
    Join Date
    Mar 2000
    Posts
    75
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How can I create SilkTest custom functions?

    Thanks for all of the feedback!

    Peter

  6. #6
    Senior Member
    Join Date
    Aug 1999
    Location
    San Diego, CA USA
    Posts
    219
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: How can I create SilkTest custom functions?

    I have common functions that I need acros multiple .t files so I made them part of my frame file. In my master frame file I just "use" the files that contain these common functions. Having them be part of the frame file makes them automatically available anywhere at all times so you don't have to remember to "use" them in your .t files.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:56 PM.

Copyright BetaSoft Inc.