You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We already support TSV format [1] which works pretty nicely with normal
text editors and other plain text tools. The biggest problems of using tab
as the delimiter are:
It's not easy to separate tab from spaces visually.
Data that should be in same column as data in above/below row moves if
more text is added before it. This makes it hard to construct data-driven
tests so that the data is represented clearly.
We could easily add a new format that would work otherwise similarly as TSV
but instead of tab the delimited would be two or more spaces. We cannot use
only one space because the actual data contains spaces, but two or more
works because we already require consecutive and leading/trailing spaces to
be escaped [2] and empty cells can be escaped with ${EMPTY} or a single
backslash.
*** Test Cases ***
Data-driven example This should work first arg second arg third arg
Another test This should work a b c
Third test This should work ${EMPTY} somewhat longer whatever
Originally submitted to Google Code by bryan.oakley on 6 Aug 2009
Have you ever considered requiring explicit delimiters around parameters instead of
using whitespace? I know it can lead to quoting hell in degenerate cases, but I like
how it makes data stand out for normal cases.
Of course, that means one has to escape quotes in an argument and there might have to
be some rule to separate test names and keywords. I could be totally wrong here, but
I think the normal case wouldn't require much escaping and make writing and reading
tests much easier, at the expense of making a few degenerate cases more difficult.
Let's look at a real world example. Say I have a library function that fetches a list
of hotels by zipcode and star rating (eg: "4 stars"). With the multiple-whitespace
proposal it might look like:
GetHotelInZipWithStars 60010 4
That's arguably not very readable. However, if the rule is "all text in quotes are
parameters, and everything else is combined to create a function name" the test could
look like this:
Get hotel in zip "60010" with "4" stars
This would also let me write assertions in a more readable style, such as:
Assert that "5" hotels were returned
Personally I would find that more preferable, though I haven't thought about it
deeply enough to know if it's truly better or merely different.
Bryan, have you looked at issue 370 ? It ought to make it possible to have keywords
like you propose without even having quotes. Using the current trunk you can already
have keywords like "Get hotel in zip ${zipcode} with ${stars} stars". Notice that you
use it with as one keyword without arguments.
Bryan, with embedded arguments explained in issue 370 you can delimit parameters any
way you want. You could for example use 'Get hotel in zip "${zipcode}" with
"${stars}" stars' if you wanted. The nice thing about this was that we didn't need to
change the test data syntax. Anyway, this discussion should be moved to issue 370 ,
into new issue, or into mailing lists.
After a little prototyping we decided to get this into 2.1.1. Implementation is
pretty trivial as the plain text parser can extend the existing TSV parser. Writing
documentation and creating tests will actually be more work.
In addition to using spaces a delimiter we prototyped also using spaces with the pipe
character. In some situations, mainly with data-driven examples, this proved to work
pretty well:
| Example Test | Add two numbers | 1 | 1 | 2 |
| Example 2 | Add two numbers | 1 | 2 | 3 |
| Example 3 | Add two numbers | 1 | -1 | 0 |
Notice that the separator is now two or more spaces + pipe + two or more spaces.
Pipes in the beginning and in the end are optional and must also have two spaces
before/after them.
It should be easy to support both "spaces only" and "spaces with pipe" formats in the
same file. The only limitation added by the latter format is that a single pipe as a
cell value needs to be escaped with a backslash.
In robot/parsing/txt_format.html Pipe Separator test fails with error:
No keyword with name '|' found.
The actual failing test is Extra Pipes At The End in suite
testdata/parsing/txt_format/pipes.txt
This happens with my Linux and Windows machines. I updated both machines, runned the
tests through run_atests.py and also reinstalled and used pybot. Same test fails all
the time.
While investigating this, found more problems in space separated and pipe separated
formats. Added tests for those problems r2187. We have still following issues to tackle:
How to use :FOR loop in space separated format?
Fix the parser so that it leaves empty cells instead of cells containing pipes when
there is multiple empty cells marked with pipes.
Originally submitted to Google Code by bryan.oakley on 13 Aug 2009
Is requiring the pipe at the end really necessary or does it just make parsing a
little easier? It seems like the key to recognizing the line is that it starts with a
pipe and a space -- correct? If so, it should be easy for the parser to handle a line
that doesn't end with a pipe.
I say this because I find that programming languages that require line terminators
are a never ending source of frustration to me. If the terminating pipe isn't
strictly necessary I'd like to suggest finding a way to make it optional.
Requiring pipe only in the beginning is a good idea.
I fixed the problem using FOR/PARALLEL with the space separated format in r2197.
The problem was that '' was left to the cell. I could have removed that while
splitting space separated rows but this change allows using '' inside FOR/PARALLEL
block with any format.
The reason all tests passed for me earlier was that I only executed tests under
parsing/data_formats directory when special cases the plain text format were in
parsing/txt_format.html. Shouldn't this file be moved under parsing/data_formats too?
Perhaps with name like txt_special_cases.html.
Found one more problem... With the pipe separated data it's not possible to have cell
with just one space like '| xxx | | yyy |'. Having two or more spaces is totally
fine. Should we change splitting so that we use regexp instead of ' | ' or should we
just require that empty cells contain at least two spaces?
Originally submitted to Google Code by bryan.oakley on 13 Aug 2009
Don't require two spaces. This new format is a user interface and deserves to be
user-friendly.
Two spaces is hard to distinguish from a single space and easy to forget to do. My
intuition tells me requiring two spaces will cause more errors and make the debugging
of those errors harder to spot.
I'm not entirely happy with this documentation but at least it ought to explain all
the technical details. Janne, could you please proofread the doc and possibly enhance
it also otherwise? Comments from others are also welcome.
Other than the doc proofreading this issue is about to be done.
Activity
spooning commentedon Jun 29, 2014
*** Test Case ***
BDD Example
Given this issue is implemented
When this syntax with spaces as delimiters is used
Then it will actually work
spooning commentedon Jun 29, 2014
*** Test Cases ***
Data-driven example This should work first arg second arg third arg
Another test This should work a b c
Third test This should work ${EMPTY} somewhat longer whatever
spooning commentedon Jun 29, 2014
Have you ever considered requiring explicit delimiters around parameters instead of
using whitespace? I know it can lead to quoting hell in degenerate cases, but I like
how it makes data stand out for normal cases.
Of course, that means one has to escape quotes in an argument and there might have to
be some rule to separate test names and keywords. I could be totally wrong here, but
I think the normal case wouldn't require much escaping and make writing and reading
tests much easier, at the expense of making a few degenerate cases more difficult.
Let's look at a real world example. Say I have a library function that fetches a list
of hotels by zipcode and star rating (eg: "4 stars"). With the multiple-whitespace
proposal it might look like:
GetHotelInZipWithStars 60010 4
That's arguably not very readable. However, if the rule is "all text in quotes are
parameters, and everything else is combined to create a function name" the test could
look like this:
Get hotel in zip "60010" with "4" stars
This would also let me write assertions in a more readable style, such as:
Assert that "5" hotels were returned
Personally I would find that more preferable, though I haven't thought about it
deeply enough to know if it's truly better or merely different.
spooning commentedon Jun 29, 2014
Bryan, have you looked at issue 370 ? It ought to make it possible to have keywords
like you propose without even having quotes. Using the current trunk you can already
have keywords like "Get hotel in zip ${zipcode} with ${stars} stars". Notice that you
use it with as one keyword without arguments.
spooning commentedon Jun 29, 2014
No, I hadn't seen that issue. I like it. I still like the idea of explicitly
delimited parameters.
spooning commentedon Jun 29, 2014
I remembered the name of the product I had seen -- Twist by ThoughtWorks.
http://studios.thoughtworks.com/twist-agile-test-automation
spooning commentedon Jun 29, 2014
Bryan, with embedded arguments explained in issue 370 you can delimit parameters any
way you want. You could for example use 'Get hotel in zip "${zipcode}" with
"${stars}" stars' if you wanted. The nice thing about this was that we didn't need to
change the test data syntax. Anyway, this discussion should be moved to issue 370 ,
into new issue, or into mailing lists.
spooning commentedon Jun 29, 2014
After a little prototyping we decided to get this into 2.1.1. Implementation is
pretty trivial as the plain text parser can extend the existing TSV parser. Writing
documentation and creating tests will actually be more work.
spooning commentedon Jun 29, 2014
In addition to using spaces a delimiter we prototyped also using spaces with the pipe
character. In some situations, mainly with data-driven examples, this proved to work
pretty well:
| Example Test | Add two numbers | 1 | 1 | 2 |
| Example 2 | Add two numbers | 1 | 2 | 3 |
| Example 3 | Add two numbers | 1 | -1 | 0 |
Notice that the separator is now two or more spaces + pipe + two or more spaces.
Pipes in the beginning and in the end are optional and must also have two spaces
before/after them.
It should be easy to support both "spaces only" and "spaces with pipe" formats in the
same file. The only limitation added by the latter format is that a single pipe as a
cell value needs to be escaped with a backslash.
spooning commentedon Jun 29, 2014
Implementation committed in r2173. We are currently finalizing tests.
spooning commentedon Jun 29, 2014
Added some more tests r2184. There is still some bug which can be repeated with the
committed tests.
spooning commentedon Jun 29, 2014
All data format tests pass on my machine with r2184. Juha, which tests fail for you?
Are you sure you have updated everything on your environment?
spooning commentedon Jun 29, 2014
In robot/parsing/txt_format.html Pipe Separator test fails with error:
No keyword with name '|' found.
The actual failing test is Extra Pipes At The End in suite
testdata/parsing/txt_format/pipes.txt
This happens with my Linux and Windows machines. I updated both machines, runned the
tests through run_atests.py and also reinstalled and used pybot. Same test fails all
the time.
spooning commentedon Jun 29, 2014
While investigating this, found more problems in space separated and pipe separated
formats. Added tests for those problems r2187. We have still following issues to tackle:
there is multiple empty cells marked with pipes.
1 remaining item
spooning commentedon Jun 29, 2014
Is requiring the pipe at the end really necessary or does it just make parsing a
little easier? It seems like the key to recognizing the line is that it starts with a
pipe and a space -- correct? If so, it should be easy for the parser to handle a line
that doesn't end with a pipe.
I say this because I find that programming languages that require line terminators
are a never ending source of frustration to me. If the terminating pipe isn't
strictly necessary I'd like to suggest finding a way to make it optional.
spooning commentedon Jun 29, 2014
Probably there is no need to require the ending pipe. I'll check that.
spooning commentedon Jun 29, 2014
I removed the need for the ending pipe r2193. Probably some more tests are still needed.
spooning commentedon Jun 29, 2014
Requiring pipe only in the beginning is a good idea.
I fixed the problem using FOR/PARALLEL with the space separated format in r2197.
The problem was that '' was left to the cell. I could have removed that while
splitting space separated rows but this change allows using '' inside FOR/PARALLEL
block with any format.
The reason all tests passed for me earlier was that I only executed tests under
parsing/data_formats directory when special cases the plain text format were in
parsing/txt_format.html. Shouldn't this file be moved under parsing/data_formats too?
Perhaps with name like txt_special_cases.html.
spooning commentedon Jun 29, 2014
Found one more problem... With the pipe separated data it's not possible to have cell
with just one space like '| xxx | | yyy |'. Having two or more spaces is totally
fine. Should we change splitting so that we use regexp instead of ' | ' or should we
just require that empty cells contain at least two spaces?
spooning commentedon Jun 29, 2014
Don't require two spaces. This new format is a user interface and deserves to be
user-friendly.
Two spaces is hard to distinguish from a single space and easy to forget to do. My
intuition tells me requiring two spaces will cause more errors and make the debugging
of those errors harder to spot.
spooning commentedon Jun 29, 2014
Yeah, I don't like requiring two spaces either. Need to fix that tomorrow.
spooning commentedon Jun 29, 2014
Fixed the problem with cells containing only one space in pipe separated data in
r2204. Regexps FTW!
spooning commentedon Jun 29, 2014
Fixed problem that data in like "foo" was processed to foo. This was caused by
inheriting the TSVParser. Implementation r2207 and test 2206.
spooning commentedon Jun 29, 2014
Documentation committed in r2237 and the HTML version is available at
http://robotframework.googlecode.com/svn/trunk/doc/userguide/RobotFrameworkUserGuide.html#plain-text-format
I'm not entirely happy with this documentation but at least it ought to explain all
the technical details. Janne, could you please proofread the doc and possibly enhance
it also otherwise? Comments from others are also welcome.
Other than the doc proofreading this issue is about to be done.
spooning commentedon Jun 29, 2014
Made some minor cleanup, closing the issue.