Forum Discussion

dhundley's avatar
dhundley
Regular Contributor
12 months ago
Solved

if statement issue

ok. this is really weird. i'm pretty sure i've look at this from every aspect but it just isn't making any sense to me. i've got the following javascript code for the OnStartTestCase and the OnStopTestCase event handlers:

 

function EventControl1_OnStartTestCase(Sender, StartTestCaseParams)
{
Log.Message(StartTestCaseParams.Name);
Log.Message(Project.TestItems.TestItem(0).TestItem(0).Name);

if (StartTestCaseParams.Name === Project.TestItems.TestItem(0).TestItem(0).Name)
{
Log.Message("OnStartTest");
}
Log.Message("OnStartTestCase");

}

 

function EventControl1_OnStopTestCase(Sender, StopTestCaseParams)
{
Log.Message(StopTestCaseParams.Name);
Log.Message(Project.TestItems.TestItem(0).TestItem(Project.TestItems.TestItem(0).ItemCount - 1).Name);
if (StopTestCaseParams.Name === Project.TestItems.TestItem(0).TestItem(Project.TestItems.TestItem(0).ItemCount - 1).Name);
{
Log.Message("OnStopTest");
}
}

 

Note that in each event handler I am logging the values that are used for the values on either side of the subsequent IF statement which uses strict equal as the operator so the Log.Message should ONLY be executed (and appear in the log) IF those two values are equal. In my Execution plan i have a group named Miscellaneous that has 4 child test items that run sequentially (you can see this in the image of the results report below). For the first test item i would expect to see the log message indicated by the green arrow because the two preceding log message are clearly equal but how in the world can the message indicated by the red arrow be getting written to the log when the values just above its IF statement are clearly not equal to each other? Is there something here i'm missing/not seeing? I'm sure it will be something so trivial that I will be tremendously embarrassed to have even asked but I've looked at this several times and nothing is jumping out to me that i have coded something wrong. Can anyone else recreate this. I'm using TestComplete 15.50.3.7 x64

 

 

  • ok. i figured it out. i did some editing and as a result i discovered i had a errant semicolon at the end of the IF statement which was, of course, terminating. i didn't see it before because i had line wrapping on and the semicolon was wrapping down to the next line and wasn't really that noticeale. sorry for the false alarm

     

     

1 Reply

  • dhundley's avatar
    dhundley
    Regular Contributor

    ok. i figured it out. i did some editing and as a result i discovered i had a errant semicolon at the end of the IF statement which was, of course, terminating. i didn't see it before because i had line wrapping on and the semicolon was wrapping down to the next line and wasn't really that noticeale. sorry for the false alarm