Forum Discussion

kevintran1308's avatar
kevintran1308
Contributor
4 years ago

How to make Passed Log with Script test

Hi, I know there is a Log.Error when a variable is wrong.

However, how to make the Passed Log if there is a right variable.

For example in Python:

if (variable == False):

   Log.Error("There is an error")

else:

   ......

 

I don't know how to make an else to make the test passing.

 

Thank you

  • tphillips's avatar
    tphillips
    4 years ago

    Basically, a test passes if there are no Error messages (or no exceptions have been thrown). So if your test never calls Log.Error(), the test will pass.

    We use Log.Checkpoint() to create "Pass" log messages in our scripts.

     

    Essentially you will have to check each variable value. If it's not what you expect, log an error message. If it is what you expect, either do nothing or use Log.Checkpoint() to create informational messages with a green check mark.

     

    Note, Log.Checkpoint() doesn't explicitly mark a test as a pass. A test will pass if there are no Error messages.

  • can you provide us some context on what you are checking with that variable value?

    for the most part, if there isn't anything concrete that you are verifying, you don't need to "assert" a "passed log" (since whatever UI interaction you are preforming will go ahead and get performed as long as there are no failures)

     

    otherwise, if you are trying to "validate" the value of a variable against some other contextual value (maybe like an object property or something) then you would create a validation checkpoint against that variable value. that way, TestComplete produces within the test logs, a step for the property checkpoint with the green check for pass or red x for fail. https://support.smartbear.com/testcomplete/docs/testing-with/checkpoints/property/about.html

    • kevintran1308's avatar
      kevintran1308
      Contributor

      So I have to check if the variables have the values in there.

      If all of them have values. The test is passed.

      If one of them does not have the value, the test is failed.

      I don't know if property checkpoint can check different variables.

      and I need to find the way to validate the test if it passes.

      • tphillips's avatar
        tphillips
        Frequent Contributor

        Basically, a test passes if there are no Error messages (or no exceptions have been thrown). So if your test never calls Log.Error(), the test will pass.

        We use Log.Checkpoint() to create "Pass" log messages in our scripts.

         

        Essentially you will have to check each variable value. If it's not what you expect, log an error message. If it is what you expect, either do nothing or use Log.Checkpoint() to create informational messages with a green check mark.

         

        Note, Log.Checkpoint() doesn't explicitly mark a test as a pass. A test will pass if there are no Error messages.