SPONSORS:






User Tag List

Results 1 to 9 of 9
  1. #1
    Junior Member
    Join Date
    Sep 2001
    Location
    Shrewsbury, MA, USA
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Returning a testcase fail

    Say if you have a test to verify that a folder exist using this code

    //code
    testcase verifyfolder (STRING svdir)

    BOOLEAN bExists

    bExists = Sys_DirExists (svdir)
    Print ("This folder exists", svdir)

    code//


    How would you get this to return the testcase as FAIL if the folder doesn't exist. Right now this testcase will pass, but the BOOLEAN expression will say False if the folder doesn't exist. Is there a way I can say if bexists = False then testcase FAIL




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

  2. #2
    Senior Member
    Join Date
    Jul 2000
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Returning a testcase fail

    There are a number of approaches you can take, depending on what you want to accomplish as an "end result".

    The simplest is probably to call LogError().

    - note - I didn't test this, just quickly slapped it in here, the syntax/logic may be flawed <grin>

    Check the online help for LogError(), ExceptLog(), Raise() and others to see some of your other alternatives. You can also check the chapter in the guide for the exception handling mechanism.

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

  3. #3
    Senior Member
    Join Date
    Jan 2001
    Posts
    750
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Returning a testcase fail

    Just a thought:

    bExists = Sys_DirExists (svdir)
    Print ("This folder exists ", svdir," : ", bExists)

    ex: This folder exists c:\windows : true
    or This folder exists c:\windows : false


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

  4. #4
    Junior Member
    Join Date
    Sep 2001
    Location
    Shrewsbury, MA, USA
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Returning a testcase fail

    Thats perfect thanks


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

  5. #5
    Junior Member
    Join Date
    Sep 2001
    Location
    Shrewsbury, MA, USA
    Posts
    19
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Returning a testcase fail

    thats perfect thank a lot

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

  6. #6
    Member
    Join Date
    Aug 2001
    Location
    Ireland
    Posts
    64
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Returning a testcase fail

    Hi,

    I have tried this example and it works. All you really need is the if statement.

    [-] testcase verifyfolder () appstate none
    [ ] STRING sTempDir
    [ ] BOOLEAN bExists
    [ ]
    [ ] sTempDir = SYS_GetDir () + "\tempdir"
    [ ] bExists = SYS_DirExists (sTempDir)
    [-] if (bExists == False)//will log an error if bExists is False
    [ ] LogError ("Testcase failed - directory doesn't exist")
    [ ] Print (bExists) // prints: FALSE
    [ ]
    [ ] SYS_MakeDir (sTempDir) // make subdirectory
    [ ] bExists = SYS_DirExists (sTempDir)
    [-] if (bExists == False)
    [ ] LogError ("Testcase failed - directory doesn't exist")
    [ ] Print (bExists) // prints: TRUE

    Hope this helps you.

    Cheers,
    Conor

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

  7. #7
    Senior Member
    Join Date
    Jul 2001
    Location
    Elizabeth, CO, USA
    Posts
    653
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Returning a testcase fail

    Seems that everyone before took the hard route. How about using the built-in Verify function, as in....

    - Dave


    ------------------
    Amelior Technology
    dreed@ameliortech.com
    WaltzingRhino.com
    A concerned Borland customer, a fly in the ointment, a wrench in the works.

  8. #8
    Senior Member
    Join Date
    Jul 2000
    Posts
    117
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Returning a testcase fail

    * !!! doh !!! *

    ... maybe we should have our own obfuscated code contest ...

    David is right -- at least for my part, I took the original code and followed that pattern. His solution is the most "elegant" (and should have been the most obvious).

    Sheesh!

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

  9. #9
    Senior Member
    Join Date
    Jul 2001
    Location
    Elizabeth, CO, USA
    Posts
    653
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Returning a testcase fail

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by Brent Rolland:
    * !!! doh !!! *

    <HR></BLOCKQUOTE>

    Well, if it's any consolation, I'm sure that we've all spent hours on creating a great function that is then shown as obsolete or unncessary.

    I spent hours one time creating a rounding function to round REAL values in SilkTest to any number of decimals specified. Worked great, and then someone showed me that the built-in Str function also does rounding in addition to converting REAL values to STRING values. Another "DOH!"

    I like to refer to those moments as "Ingenious solutions to non-existent problems." Makes me feel better.

    - Dave


    ------------------
    Amelior Technology
    dreed@ameliortech.com
    WaltzingRhino.com
    A concerned Borland customer, a fly in the ointment, a wrench in the works.

 

 

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 11:08 AM.

Copyright BetaSoft Inc.