Skip to content

New plain text test data format #375

Closed
Closed

Description

@spooning

Originally submitted to Google Code by @pekkaklarck on 6 Aug 2009

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.

[1]
http://robotframework.googlecode.com/svn/tags/robotframework-2.1/doc/userguide/RobotFrameworkUserGuide.html#tsv-format
[2]
http://robotframework.googlecode.com/svn/tags/robotframework-2.1/doc/userguide/RobotFrameworkUserGuide.html#handling-whitespace

Activity

  1. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 6 Aug 2009

    *** Test Case ***

    BDD Example
    Given this issue is implemented
    When this syntax with spaces as delimiters is used
    Then it will actually work

  2. added this to the 2.1.1 milestone on Jun 29, 2014
  3. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 6 Aug 2009

    *** 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

  4. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    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.

  5. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 6 Aug 2009

    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.

  6. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by bryan.oakley on 6 Aug 2009

    No, I hadn't seen that issue. I like it. I still like the idea of explicitly
    delimited parameters.

  7. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor
  8. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 6 Aug 2009

    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.

  9. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 12 Aug 2009

    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.

  10. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 12 Aug 2009

    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.

  11. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 12 Aug 2009

    Implementation committed in r2173. We are currently finalizing tests.

  12. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @jrantanen on 12 Aug 2009

    Added some more tests r2184. There is still some bug which can be repeated with the
    committed tests.

  13. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 12 Aug 2009

    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?

  14. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @jrantanen on 12 Aug 2009

    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.

  15. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @jrantanen on 13 Aug 2009

    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.
  16. 1 remaining item

  17. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    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.

  18. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @jrantanen on 13 Aug 2009

    Probably there is no need to require the ending pipe. I'll check that.

  19. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @jrantanen on 13 Aug 2009

    I removed the need for the ending pipe r2193. Probably some more tests are still needed.

  20. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 13 Aug 2009

    1. Requiring pipe only in the beginning is a good idea.

    2. 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.

    3. 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.

  21. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 13 Aug 2009

    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?

  22. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    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.

  23. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 13 Aug 2009

    Yeah, I don't like requiring two spaces either. Need to fix that tomorrow.

  24. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 14 Aug 2009

    Fixed the problem with cells containing only one space in pipe separated data in
    r2204. Regexps FTW!

  25. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @jrantanen on 14 Aug 2009

    Fixed problem that data in like "foo" was processed to foo. This was caused by
    inheriting the TSVParser. Implementation r2207 and test 2206.

  26. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 16 Aug 2009

    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.

  27. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @yanne on 17 Aug 2009

    Made some minor cleanup, closing the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions