BDD-style Testcases with additional Data Tables?

329 views
Skip to first unread message

Thomas Jaspers

unread,
Nov 12, 2009, 10:57:52 AM11/12/09
to robotframework-users
Hi,

I really like the BDD-style that is possible with Robot now like

Given ...
When ...
Then ...

But what I am missing (or maybe I simply do not know how to do this)
would be a possibility to add a table
with additional parameter-values that are then tested the same way,
like.

Given my number is 10
when my number can be divided by 2
then the result should be 5

Same is true for
20 2 10
30 2 15
40 2 20

Sure I could create a table for this where I repeat the keyword in
front and then give the parameters, but
the real problem with this approach would be that I have to repeat my
keyword implementation to some extend
in my understanding.

Any idea how this could be solved or could this be an additional
feature otherwise?

Thanks & Cheers
- Thomas


Pekka Klärck

unread,
Nov 15, 2009, 8:46:08 PM11/15/09
to jas...@codecentric.de, robotframework-users
2009/11/12 Thomas Jaspers <jas...@codecentric.de>:

There's no special support for this feature. The easiest way to handle
this would be having keyword like 'Divided by two' that takes the
original number and expected results as arguments. This keyword could
then be used in data-driven manner [1] but the keyword needs to be
repeated every time.

Repeating the keyword in data-driven tests is somewhat annoying and we
plan to make that easier in RF 2.2. There's one idea in the tracker
already [2] but I'm not entirely happy about it. More ideas and
comments are highly welcome. The less new syntax the idea needs the
better as also RIDE and other tools should handle it.

[1] http://robotframework.googlecode.com/svn/tags/robotframework-2.1.2/doc/userguide/RobotFrameworkUserGuide.html#data-driven-style
[2] http://code.google.com/p/robotframework/issues/detail?id=390

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

AndreasEK

unread,
Nov 16, 2009, 12:21:34 PM11/16/09
to robotframework-users
Hi all,

this is our preferred solution on how to do executable specs:

http://blog.codecentric.de/en/2009/11/givenwhenthen-und-beispieltabellen-mit-dem-robot-framework/

Regarding the proposal in the tracker, I'd go for alternative 1, but
it doesn't make much of a difference. Our table would just look like
this (that layout is going to break in this post dues to non-
monospaced fonts, but you get the idea)

| *Test Case* | | *Closed Period* | *Open Period* |
*Run Import On* | *Old Manager Stops* | *New Manager Starts* |
| 1 | Example | 1.11.2009 - 30.11.2009 | 1.12.2009 - 31.12.2009 |
11.11.2009 | 30.11.2009 | 1.12.2009
| 2 | | 1.11.2009 - 30.11.2009 | 1.12.2009 - 31.12.2009 |
1.11.2009 | 31.10.2009 | 1.11.2009
| 3 | | 1.11.2009 - 30.11.2009 | 1.12.2009 - 31.12.2009 |
1.12.2009 | 30.11.2009 | 1.12.2009

Kindest Regards,
Andreas Ebbert-Karroum

Pekka Klärck

unread,
Nov 16, 2009, 2:25:29 PM11/16/09
to Andreas...@gmx.de, robotframework-users
2009/11/16 AndreasEK <Andreas...@gmx.de>:

>
> this is our preferred solution on how to do executable specs:
>
> http://blog.codecentric.de/en/2009/11/givenwhenthen-und-beispieltabellen-mit-dem-robot-framework/

Very nice and clever! I hope you and others keep experimenting with
different possibilities to create BDD style tests with Robot
Framework. If you got new ideas on how to make it easier, we can add
more enhancements to RF 2.2.

Thomas Jaspers

unread,
Nov 17, 2009, 4:35:11 AM11/17/09
to robotframework-users


On 16 Nov., 20:25, Pekka Klärck <p...@iki.fi> wrote:
> If you got new ideas on how to make it easier, we can add
> more enhancements to RF 2.2.
>

One idea would be to have a possibility to define words that are
ignored in BDD-style tests ... currently given/when/then, so it
would be good to have those either configurable or at least support
for other languages.

Reasoning for this is that when you are working with bigger - in our
case german - companies it is not always the case that English
is accepted as a language for defining tests and of course in BDD-
style it makes especially sense to have them written in a way everyone
really understands them in the end :).

Pekka Klärck

unread,
Nov 17, 2009, 10:33:26 AM11/17/09
to jas...@codecentric.de, robotframework-users
2009/11/17 Thomas Jaspers <jas...@codecentric.de>:

>
> One idea would be to have a possibility to define words that are
> ignored in BDD-style tests ... currently given/when/then, so it
> would be good to have those either configurable or at least support
> for other languages.

I've been thinking about this too. What would be a good way to
configure these? Should configuration be data file, execution round,
or environment based?

Cucumber has this feature too and these words have been translated to
many different languages. Could we possibly reuse those translations?

Thomas Jaspers

unread,
Nov 18, 2009, 3:57:32 AM11/18/09
to robotframework-users
On 17 Nov., 16:33, Pekka Klärck <p...@iki.fi> wrote:

> I've been thinking about this too. What would be a good way to
> configure these? Should configuration be data file, execution round,
> or environment based?
>
> Cucumber has this feature too and these words have been translated to
> many different languages. Could we possibly reuse those translations?
>

Hmm, however it is configured I think it must be ensured that tests
can still be "moved"
from one Robot Installation to another without the need to reconfiutre
anythingand they must still run. Thus if configuration is
used this must be somehow configured as part of the testsuites.

Otherwise I think having these words translated would be fine as
well :-)

Cheers
- Thomas
Reply all
Reply to author
Forward
0 new messages