Forum Discussion

SlickRick's avatar
SlickRick
Frequent Contributor
2 years ago

Test Fails When Running with Tag: Double Parameter Default Issue

Hey, fellow community,

 

I'm facing an intriguing issue with one of my tests, and I was hoping to get some insights from you all. Here's the problem:

I have a test that includes an optional double parameter, and its default value is set to 10000. When I manually run the test, everything works perfectly, and the default value of 10000 is used as expected.

 

However, the trouble starts when I try to run the test using the tag. I use the right-click option on the project and run the test with the tag '@tag'. Surprisingly, the test fails, and upon further investigation, I noticed that the value used for the double parameter is 0 instead of my intended default value of 10000.

 

I've already double-checked the tag setup and made sure everything looks correct. It's puzzling why the default value is being ignored when using the tag, leading to the failure.

 

Has anyone encountered a similar issue before or have any ideas about what might be causing this discrepancy? I'd greatly appreciate any suggestions, tips, or experiences you can share to help me troubleshoot this problem and get my test running successfully with the tag.

 

Thank you all in advance for your support and insights! 

  • FYI, for now a workaround that works is to create another test that simply call this the parametrized test and set the tag on that new test.

     

    However i think that this is a bug. 

    • SlickRick's avatar
      SlickRick
      Frequent Contributor

      This is a great video, sadly it doesn't fix the issue im facing 😞.

      Ill make sure to keep that in reference thought.!

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    See,

     

    https://support.smartbear.com/testcomplete/docs/testing-with/running/messages/test-uses-required-non-optional-parameters.html

     

    https://support.smartbear.com/testcomplete/docs/working-with/managing-projects/project-editor/dialogs/routine-parameters.html

     

    When I have specified a tag for keyword test, with two parameters, and the parameters are set to optional, with default values set. Running the keyword test will display the values using Log,

    However, running execution plan with tag expression, results in values not being shown,

     

    This is definitely a bug. Well spotted SlickRick 

  • Mary09's avatar
    Mary09
    Occasional Visitor

    You can use debugging techniques to inspect the state and values of variables during test execution with the tag. This can help you identify any discrepancies in the test flow.

  • SlickRick's avatar
    SlickRick
    Frequent Contributor

    Im a new user so im still learning. 

     

    So I added a Log Message to my test, when I run it manually, it shows the right default value.



     

    When I run it using the @Sanity tag then it outputs nothing:

     

     

    And i have the following details:

    The elapsed time 9599 (ms) is greater than MaxExecTime 0 (ms).


    One thing i noticed is that if i go on the execution plan, the execution entity is set to "KeywordTests - LoadTimeTest" and have parameters defined:

     

    And if i change the execution entity to the tag it has no parameters...:

     

    Since im new, i might just be misusing the tool... 😕

     

     

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I can only seem to get tags working for scripts, but not keyword tests!

  • SlickRick's avatar
    SlickRick
    Frequent Contributor

    I have created an example project (see attachment).

     

    Basically to make it fail, run the sanity tag:

     

     

    and to make it work, run the test itself directly or using the execution plan.

     

    Im a bit confused...

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    From what I understand, it's not possible to run a test with tag and pass parameters via execution plan. However, you can run the keyword test using default parameters - you'll get the following message appearing

     

    • SlickRick's avatar
      SlickRick
      Frequent Contributor

      Hi rraghvani, thanks for your reply.

       

      I understand that it is not possible to run a test flag via testexecution, after thinking about it does make sense since it may run more than one test (all tests with that flag). However i would still expect to see tests which have optional parameter with default values being called correctly.

       

      In your case, your parameter seems to be defined as non-optional. In my case it is optional and have a default defined. Therefore i would expect no messages and have the test use the default.

       

      However in my case it seems like the default is not used and ignored (thus using 0 instead).


  • SlickRick's avatar
    SlickRick
    Frequent Contributor

    FYI, for now a workaround that works is to create another test that simply call this the parametrized test and set the tag on that new test.

     

    However i think that this is a bug. 

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      SlickRick :

      Hi,

       

      Sorry for the late jumping in...

      I do not think that this is a bug and would treat it as expected behavior.

      The reason is that Execution Plan and execution by tag are separate unrelated entities. It is possible to add the same script routine/keyword test into Execution Plan more than once as separate tests and provide different parameter values for every entry. Also, Execution Plan may not contain test entry for some script routine/keyword test but this script routine/keyword test still can be called and executed by tag.

       

      You can still use your current approach with the wrapper that calls your test with expected parameter value. If it is possible to provide default value for the optional parameter, you can also set default value to some obviously incorrect value (say, to -2 (minus two) and then, at the start of the test check parameter's value. If it equals to -2 then set it to the value that you need (this means that test was called by tag) and leave it as it is otherwise (which means test was called from Execution Plan).

       

      Another technique that might work is to check in your test if TestItems.Current object exists. If it does, this means that your test was called from Execution Plan. See https://support.smartbear.com/testcomplete/docs/reference/project-objects/project/testitems/current.html for more details.

       

      • SlickRick's avatar
        SlickRick
        Frequent Contributor

        Well thats the thing.

         

        Unless i missunderstood, with the approach you have suggested (to put the default value to -2) it would not work if run by the tag. That value would be nothing and therefore treated as 0.

        My test does have a default value defined for the parameter. But when ran through the tag, that parameter is "ignored" and set to nothing.