robotframework-lint icon indicating copy to clipboard operation
robotframework-lint copied to clipboard

Rule for complex logic in test cases

Open guykisel opened this issue 10 years ago • 2 comments
trafficstars

According to https://code.google.com/p/robotframework/wiki/HowToWriteGoodTestCases#Workflow_tests test cases should not contain complex logic like for loops or if statements. Detecting for loops seems pretty easy, but detecting if/else and variable assignments seems like it might be a little trickier unless you hardcode a list of disallowed keywords, such as Run Keyword If.

guykisel avatar Dec 02 '14 22:12 guykisel

Hmmm. I'm not sure we should have a built-in rule checking for :FOR statements. There are definitely some very valid uses. I'll consider it though. Maybe if you have more than one for loop, or nested for loops?

Perhaps a more general solution would be a generic "check for illegal keywords", then you can edit an external file that lists the keywords your team doesn't want to use. You could include ":FOR", for example, if you want to flag uses of for loops.

On Tue, Dec 2, 2014 at 4:08 PM, Guy Kisel [email protected] wrote:

According to https://code.google.com/p/robotframework/wiki/HowToWriteGoodTestCases#Workflow_tests test cases should not contain complex logic like for loops or if statements. Detecting for loops seems pretty easy, but detecting if/else and variable assignments seems like it might be a little trickier unless you hardcode a list of disallowed keywords, such as Run Keyword If.

— Reply to this email directly or view it on GitHub https://github.com/boakley/robotframework-lint/issues/10.

boakley avatar Dec 02 '14 22:12 boakley

:FOR statements are definitely valid in keywords. I think the "good test cases" guide is just recommending that there be no :FOR loops at the top level of a test case. It's certainly debatable what an acceptable level of complexity is, though.

guykisel avatar Dec 02 '14 22:12 guykisel