Multiline comments in Robot framework

Siya picture Siya · Sep 30, 2014 · Viewed 38.7k times · Source

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

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

Answer

Bryan Oakley picture Bryan Oakley · Oct 1, 2014

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.