Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiline comments in Robot framework

Is there is any way to comment multiple lines in Robot framework.

In python we have option like ''' and ''''.

like image 281
Siya Avatar asked Sep 30 '14 20:09

Siya


People also ask

How do you comment multiple lines in Robot Framework?

One other trick for those who want to comment in and out a lot of lines is to use ctrl + / . That will comment out either the line that your cursor is on, or whatever lines you have highlighted. You can then highlight the lines and use ctrl + / again to un-comment them.

How do you comment lines in a robot file?

Lines starting with the # character are ignored by Robot Framework and are used for comments like in this example: # This is a code comment.

How do you insert a multi-line comment?

To comment out multiple code lines right-click and select Source > Add Block Comment. ( CTRL+SHIFT+/ ) To uncomment multiple code lines right-click and select Source > Remove Block Comment. ( CTRL+SHIFT+\ )

Which is the correct way to put multi multiline comment?

Unlike other programming languages such as JavaScript, Java, and C++ which use /*... */ for multi-line comments, there's no built-in mechanism for multi-line comments in Python. To comment out multiple lines in Python, you can prepend each line with a hash ( # ).


2 Answers

No, you have to use # in front of every line you want to comment.

Nevertheless note that:

  • if you are working with plain text format files, the whole test before your first section (settings, variable or test cases) is free text and you don't have to comment it.
  • some IDE propose shortcuts to comment multiple lines in one shot, for instance Ctrl+/ (or Command+/ if you're on Mac) for PyCharm.
like image 122
Laurent Bristiel Avatar answered Sep 21 '22 15:09

Laurent Bristiel


There is no block comment feature. However, there's a subtle little trick you can use to comment out whole blocks. It's not documented to be a multiline comment feature but it can be used like that.

This trick works by knowing that robot will ignore any data in tables that are not one of the four recognized tables: keywords, tests, settings or variables. If you have some other table, anything under it up until the next table will be ignored.

The relevant section of the user guide says this:

2.1.4 Rules for parsing the data

Ignored data

When Robot Framework parses the test data, it ignores:

  • All tables that do not start with a recognized table name in the first cell.
  • ...

For example:

*** Test Cases *** 
| test 1 
| | log | this is test one

*** comment ***
| test 2
| | log | this is test two

*** Test Cases ***
| test 3
| | log | this is test three

If you run the above test you'll see that only test 1 and test3 are executed. Everything in the "comment" table are ignored.

like image 45
Bryan Oakley Avatar answered Sep 17 '22 15:09

Bryan Oakley