Forum Discussion

kimmyh51's avatar
kimmyh51
Contributor
12 years ago

Better syntax reporting (pls comment if u want 2)

Hi - please excuse the 'txt spk' in the title, it was the only way to say everything I wanted to say within the 80 char limit



I use C# in test complete (so dont get the pop up syntax error dialogue that I think is available in some of the other scripting languages - but not sure that would make any difference anyway).





The problem I find with the code editor is that if I leave out a bracket, or put one in the wrong place or quotes - something little like that I can spend ages looking for it as 9 times out of ten the error (little red cross) is on a completely different line, and often completely different script function to where I have left out the bracket or quote.

The error message is almost always 'object expected' which basically useless in letting me know what I have done wrong, or where to start looking. 

The worst one is when I have accidentally put in one too many } or not enough in a piece of code with lots of if statements etc.



I also have found that many times a script will execute and then fail with an object expected error, on a really basic syntax error - something Id expect to be picked up before it ever gets to executing the code.



Are there any plans to improve the error reporting on the code editor to provide some clues to those of us who are looking for a bracket or quote shaped 'needle' in a bracket, quote and parenthesis shaped 'haystack?' :)

Hopefully there will be other people who would like this as well who might post and bump it up the priority list...?



thanks



6 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Kim,



    The current approach is to hover mouse over the error icon (that one with the red cross) - quite often the appeared tooltip message provides a good idea of what and where went wrong.
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Kim,


    To check whether it is a TestComplete bug, I'd ask you to contact our Support Team, describe the problem and send them a test project (or at least a script unit) demonstrating the issue. Guys will check if it is TestComplete that causes the problem and let you know their results.


    >> I also have found that many times a script will execute and then fail with an object expected error

    A bracket indicates an operation that can be executed on an object. If that line is not executed, no error occurs.

    You can try playing with syntax highlighting settings of the Code Editor. Try using some bright color for string constants. Large blocks of bright text will indicate you forgot to set a quote.

  • Hi



    I am using C# there is no tool tip for syntax checking (the help files state this too)

    the object expected errors i am referring to are ones that when I finally find the cause are syntax errors



    I am referring not to test complete having a bug on processing objects - but the fact that when a quote, bracket etc has been left out, the error is absolutely useless to me in locating the syntax error.



    This is for the C# scripting language - not Jscript, VB etc.



    I am now having multiple crashing issues with TC 9 which mean i cant post any screenshots right now as it isnt running

  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    >> but the fact that when a quote, bracket etc has been left out, the error is absolutely useless to me in locating the syntax error.

    Yes, I understand this. Depending on the problem, the error text can be provided by TestComplete or by the scripting engine. C#Script is based on JScript, which is not a SmartBear product. That is why, I asked you to send a sample to our Support Team, so that we can explore the situation and fix the bug, if it is a TestComplete bug.


    >> I cant post any screenshots right now as it isnt running

    If you see TestComplete's dialog asking you to send a report when a crash occurs, send a report to SmartBear from this dialog. Typically, crashes require investigating and collecting additional data, which, in many cases, the reports already contain. 

  • the attached is not the best example, but gives an idea of what I mean






    In the attached screeenshot the syntax error is an "if, and" statement with no 'and' criteria or closing brackets etc.




    Yet the error is not reported in the line that the syntax error is, or the one following.





    I have had this happen where I get a little red X at the bottom of a page with up to 200 lines of code, and I have the x at the bottom and eventually find the syntax error, 100 lines or so above it.  Usually in the form of a missing bracket.  Often there are several functions bnetween the location of the little red x and the actual error.



    The most common one will be where I have :



    a script unit with say, 10 functions in it



    function 3 has 3 if statements

        the 3rd if statement has no closing parenthesis



    and the red X is at the bottom of the script unit at the end of function 10



    Id have thought it would at least be at the end of function 3 - or start of function 4 (does it not check when a new function statement is made, that all closing/opening parenthesis are present for declarations in the function immediately prior?)