this is more a question for robotframework-users, nevertheless here's
an answer :) The following works:
*** Test Cases ***
Device Component Baseline Information
:FOR ${dc} IN RANGE 3
\ Validate Device Component Baseline Information ${dc}
*** Keywords ***
Validate Device Component Baseline Information
[Arguments] ${whichdc}
[Documentation] Example implementation
Log ${whichdc}
Note the \ in the line after the :FOR.
I think this special requirement for plain text syntax should be added
to the documentation, or at least an example. I'll create an issue for
that.
Regards,
Robert
2011/9/1 Piotr Nestorow <piotr.n...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "robotframework-devel" group.
> To post to this group, send email to robotframe...@googlegroups.com.
> To unsubscribe from this group, send email to robotframework-d...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/robotframework-devel?hl=en.
>
>
This topic has actually been discussed on rf-users recently so I'll
add also that list to Cc. Possible future replies can, in my opinion,
be sent only to rf-users.
> 1. I want to use [Template] for a data driven test case.
> The idea is of course that I don't want the test case to stop when a
> particular iteration fails.
That ought to work out-of-the-box already.
> 2. Also I need the number of iterations to be computed on the fly
> before the loop.
>
> The following example shows the idea
> - Note that 'Device Component Baseline Information' works but requires
> the very technical
> 'Run Keyword And Continue On Failure'
> - 'Device Component Baseline Information Template' does not work
>
> ------------------------------------------------------------------------------
> *** Test Cases ***
> Device Component Baseline Information
> ${dcs} = Number Of Device Components
> :FOR ${dc} IN RANGE ${dcs}
> \ Run Keyword And Continue On Failure Validate DC ${dc}
>
> Device Component Baseline Information Template
> ${dcs} = Number Of Device Components
> [Template] Validate DC
> :FOR ${dc} IN RANGE ${dcs}
> \ ${dc}
>
> *** Keywords ***
> Number Of Device Components
> [Documentation] Returns the number of DCs
> [Return] 3
>
> Validate DC [Arguments] ${which dc}
> [Documentation] Validate DC baseline information
> Log ${which dc}
The problem is that you try to have a workflow (getting a variable and
then using it) in a test case that has a template. That doesn't work,
but the preconditions can be done in test or suite setup. For example
this could work for you:
*** Test Cases ***
Device Component Baseline Information Template
[Setup] Set DCS Variable
[Template] Validate DC
:FOR ${dc} IN RANGE @{DCS}
\ ${dc}
***Keywords***
Set DCS Variable
${dcs} = Number Of Device Components
Set Test Variable \@{DCS} ${dcs}
> - As a side note: In the [Template] solution I'd like to have a test
> case generated for every loop iteration.
> This would improve our test case statistics :)
This would be rather hard to implement and I'm nor sure everyone would
like that (at least I wouldn't). If you want to have separate tests
for all iterations, you should not use templates but just have
separate tests instead. I know that you cannot then use for loops in
the data like this, but it would be pretty simple to generate the
whole test data based e.g. some model.
Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org