HowToWriteGoodTestCases icon indicating copy to clipboard operation
HowToWriteGoodTestCases copied to clipboard

Variables naming convention

Open lucielavickova opened this issue 5 years ago • 2 comments

Hello,

just as an improvement suggestion - from my own experience it's better to use underscores between words in variable names rather than spaces - it helps a lot (not only) during refactoring:

  • I can select the whole variable name by a double-click and see where it's used (because PyCharm highlights it)
  • when searching & replacing a variable name with underscores it's less likely that I would accidentally replace some part of a code I don't want (test case name or documentation - these usually contain the spaces between words)

Example of our naming convention: ${GLOBAL_VARIABLE} ${keyword_parameter}

lucielavickova avatar Aug 19 '19 12:08 lucielavickova

Hello,

I'm not sure than using case to differentiate global variable is a good things because we easily can shadow a global/suite variable using same lower name in a keyword. Perhaps it is better to use dedicated prefix.

vmaillol-altair avatar Jun 05 '20 09:06 vmaillol-altair

Hello,

I'm not sure than using case to differentiate global variable is a good things because we easily can shadow a global/suite variable using same lower name in a keyword. Perhaps it is better to use dedicated prefix.

As someone that got bitten by this issue just now, I'll wholeheartedly support this notion to use a prefix for this purpose. We have already used capital letters and underscores for global variable names, but a local variable got declared with a camelcase name (which is treated as equivalent) and the value was reset in the next test case to the globally set value.

adamzovits avatar Nov 13 '23 15:11 adamzovits