Multiline arguments for text based robot tests

1,771 views
Skip to first unread message

Paolo Bizzarri

unread,
Aug 17, 2018, 5:08:58 AM8/17/18
to robotframework-users
Hi,

I am looking at a large suite of Robot Framework tests (1000+ tests).

I would like to migrate them in text format from HTML  because HTML is hard to mantain.

The biggest obstacle at the moment is multiline arguments - typically results from queries. They would appear horribly on a single line.

I saw that there was some discussion about it, but apparently there was only an option for variables, which is not a feasible option - we would have to refactor a large number of tests, plus we would reduce the visibility.

Any suggestion?

Thanks

Paolo Bizzarri

Hélio Guilherme

unread,
Aug 17, 2018, 6:17:49 AM8/17/18
to robotframework-users
You are in right path. HTML format is being deprecated.

Fortunately, Pekka Klarck created a tool for doing those conversions.
See Tidy documentation here.



--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.



--
My Favorite Open Source Projects
awsome-lists gretl meld robotframework wxPython

Paolo Bizzarri

unread,
Aug 17, 2018, 8:05:01 AM8/17/18
to robotframework-users
Hi Hélio,

thanks for pointing me to tidy, I had already seen that something like that was around.

The problem for me is that I have multine arguments in my tests - typically query results - and I can't see a way to replicate them inside a text based test without using variables - which would not be nice.

Is that anything that I can try to hack around to obtain this result?

Regards

P.


Il giorno venerdì 17 agosto 2018 12:17:49 UTC+2, Hélio Guilherme ha scritto:
You are in right path. HTML format is being deprecated.

Fortunately, Pekka Klarck created a tool for doing those conversions.
See Tidy documentation here.


On Fri, Aug 17, 2018 at 10:05 AM, Paolo Bizzarri <pib...@gmail.com> wrote:
Hi,

I am looking at a large suite of Robot Framework tests (1000+ tests).

I would like to migrate them in text format from HTML  because HTML is hard to mantain.

The biggest obstacle at the moment is multiline arguments - typically results from queries. They would appear horribly on a single line.

I saw that there was some discussion about it, but apparently there was only an option for variables, which is not a feasible option - we would have to refactor a large number of tests, plus we would reduce the visibility.

Any suggestion?

Thanks

Paolo Bizzarri

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.

Hélio Guilherme

unread,
Aug 17, 2018, 8:44:22 AM8/17/18
to robotframework-users
Can you create an example? 
Maybe we could do some pre-processing to transform it in non-multiline, or to call some python parser keyword?
Also if you think it could be an enhancement to Tidy, we could think on implementing it.



On Fri, Aug 17, 2018 at 1:05 PM, Paolo Bizzarri <pib...@gmail.com> wrote:
Hi Hélio,

thanks for pointing me to tidy, I had already seen that something like that was around.

The problem for me is that I have multine arguments in my tests - typically query results - and I can't see a way to replicate them inside a text based test without using variables - which would not be nice.

Is that anything that I can try to hack around to obtain this result?

Regards

P.

Il giorno venerdì 17 agosto 2018 12:17:49 UTC+2, Hélio Guilherme ha scritto:
You are in right path. HTML format is being deprecated.

Fortunately, Pekka Klarck created a tool for doing those conversions.
See Tidy documentation here.


On Fri, Aug 17, 2018 at 10:05 AM, Paolo Bizzarri <pib...@gmail.com> wrote:
Hi,

I am looking at a large suite of Robot Framework tests (1000+ tests).

I would like to migrate them in text format from HTML  because HTML is hard to mantain.

The biggest obstacle at the moment is multiline arguments - typically results from queries. They would appear horribly on a single line.

I saw that there was some discussion about it, but apparently there was only an option for variables, which is not a feasible option - we would have to refactor a large number of tests, plus we would reduce the visibility.

Any suggestion?

Thanks

Paolo Bizzarri

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsubscrib...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.



--
My Favorite Open Source Projects
awsome-lists gretl meld robotframework wxPython

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframework-users@googlegroups.com.

Pekka Klärck

unread,
Aug 17, 2018, 9:07:06 AM8/17/18
to pib...@gmail.com, robotframework-users
pe 17. elok. 2018 klo 12.08 Paolo Bizzarri (pib...@gmail.com) kirjoitti:
>
> I am looking at a large suite of Robot Framework tests (1000+ tests).
>
> I would like to migrate them in text format from HTML because HTML is hard to mantain.

That's a good idea. The support for the HTML format is going to be
deprecated in the forthcoming RF 3.1 and removed in RF 3.2.

> The biggest obstacle at the moment is multiline arguments - typically results from queries. They would appear horribly on a single line.
>
> I saw that there was some discussion about it, but apparently there was only an option for variables, which is not a feasible option - we would have to refactor a large number of tests, plus we would reduce the visibility.

Is the problem that you currently have long strings in HTML that wrap
in table cells and the plain text format doesn't support that? Things
you can try:

1. If a keyword accepts several arguments but individual arguments
aren't overly long, you can just use `...` to split arguments into
multiple lines:

Example Keyword This argument is rather long but not super long.
... This is another pretty long, but not super long, argument.
... One more longish argument here.

2. If an individual argument is very long, you can use the `Catenate`
keyword to construct it utilizing the aforementioned `...` syntax:

${argument} = Catenate
... This is the first part of a very long argument.
... This is the second part.
... These parts are concatenated together with a space.
Example Keyword ${argument}

${argument} = Catenate SEPARATOR=\n
... It is possible to specify a custom separator by using `SEPARATOR=<sep>`.
... This example contains two lines.
Example Keyword ${argument}

3. You said you wouldn't like to use variables, but they can be pretty
handy, especially if you need the same value multiple times. Long
variables, including multiline variables, can be created using the
same logic as with the `Catenate` keyword:

*** Variables ***
${EXAMPLE 1} Quite long value but short enough to fit into
one line nicely.
${EXAMPLE 2} This value is so long that it makes sense to split it into
... multiple lines. By default the value is
concatenated together
... by using spaces.
${EXAMPLE 3} SEPARATOR=\n
... It is possible to use a custom separator when splitting
... a variable into multiple lines. This example creates
... a multiline value.

4. If your keyword accepts single long argument that you'd like to
split into multiple lines in Robot's data, you can create a wrapper
keyword that accepts parts separately and uses `Catenate` to combine
them:

*** Keywords ***
Wrapper Example
[Arguments] @{arguments}
${argument} = Catenate @{arguments}
Keyword Accepting Only One Argument ${argument}

5. If values are really long, it often makes sense to store them in
external files. This keeps Robot data simpler and typically also makes
editing the external data a lot easier. For example, Robot's own XML
library allows passing XML both as a string like
`<example>content</example>` or as a path like `${CURDIR}/data.xml`.
This makes it possible to have simple XML snippets inline in Robot's
tests data, possibly using some of the ideas explained above, but
allows also storing larger XML snippets as external files that can
then be edited with a dedicated XML editor.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Paolo Bizzarri

unread,
Aug 17, 2018, 9:20:39 AM8/17/18
to robotframework-users
Ok, let me try to explain a bit better.

The product I am working on is kind of a multidimensional database.

So one of my typical tests are something like this.

| TestName | (This is the keyword) Execute Query on a Cube | (this is the query) select a, b, c from cube X | | (this is the expected result) multiline result, typical five to ten lines.

Typically both the query and the result is a multiline argument. In some cases we have other multiline parameters for various configuration.

Does this make more sense?

Thanks and regards.

P.
Hi Hélio,
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.



--
My Favorite Open Source Projects
awsome-lists gretl meld robotframework wxPython

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Paolo Bizzarri

unread,
Aug 17, 2018, 10:37:15 AM8/17/18
to robotframework-users
Hi Pekka,

thanks for the detailed answer!

Yes, we need to migrate away from HTML. From what you say it seems like we will have to go through some form of minor or major rewriting for our tests. 

I think we will need to look into tidy and possibly see if we can add something custom for us to automate part of the rewriting.

Thanks a lot for your work.

Regards

P.

Pekka Klärck

unread,
Aug 20, 2018, 9:44:27 AM8/20/18
to Paolo Bizzarri, robotframework-users
pe 17. elok. 2018 klo 17.37 Paolo Bizzarri (pib...@gmail.com) kirjoitti:
>
> Yes, we need to migrate away from HTML. From what you say it seems like we will have to go through some form of minor or major rewriting for our tests.
>
> I think we will need to look into tidy and possibly see if we can add something custom for us to automate part of the rewriting.

I'd just use Tidy, see how the results look, and then think can
results be automation be enhanced or would it be easier to just do
manual cleanup. If you end up automating this, perhaps the
enhancements could be incorporated to Tidy itself.

> Thanks a lot for your work.

Thanks for compliments!
Reply all
Reply to author
Forward
0 new messages