[TIP] Fwd: - ATP problem
Pekka Klärck
peke at iki.fi
Thu Sep 10 01:33:44 PDT 2009
2009/9/10 yoav glazner <yoavglazner at gmail.com>:
> The issue with robot was the lack of abilty to define tables of data in a
> clear way.
>
> here is how i do it in fitteness
>
> !|SetUpProjects|
> |Name|Number|
> |pop |1 |
> |corn |2 |
>
> =>
>
> Class SetUpProjects(object):
> def setName(self,name):
> self.name
> def setNumber(self,number):
> Project(name=self.name,number=number) #using sqlElixir
With Robot Framework you could use the exact same test library code
(test library == fixture in Fit terminology) like this:
***Settings***
Library SetUpProjects
***Test Cases***
Example Test 1
Set Name pop
Set Number 1
Example Test 2
Set Name corn
Set Number 2
You could also create a new higher level keyword in the test data and
use it in your test as illustrated below. This style is pretty close
to your Fitnesse example.
***Test Cases***
| Example Test 1 | Setup Project | pop | 1 |
| Example Test 2 | Setup Project | corn | 2 |
***Keywords***
Setup Project [Arguments] ${name} ${number}
Set Name ${name}
Set Number ${number}
You could obviously also have 'Setup Project' keyword in your
fixture/library, but this possibility to create new higher level
keywords in the test data makes it easier for non-programmers to
create automated tests using appropriate abstraction level. You can
have simple and generic test libraries but still create tests that use
workflow style (the first example), data-driven approach (the second
example), or even behavior driven development style like below:
***Test Cases***
BDD Example
Given a user creates a project named pop with id 1
When ...
Then ...
***Keywords***
Given a user creates a project named ${name} with id ${number}
Set Name ${name}
Set Number ${number}
Notice that all these examples use the same SetupProjects library and
there really is no need for any more glue code. If someone is
interested to learn more the best place to start is the quick start
guide [1]. The last example uses new functionality currently best
explained in the user guide [2]. Note also that these examples can
actually be execute when using RF 2.1.1 and the new plain text data
format [3].
[1] http://code.google.com/p/robotframework/wiki/QuickStartGuide
[2] http://robotframework.googlecode.com/svn/tags/robotframework-2.1.1/doc/userguide/RobotFrameworkUserGuide.html#embedding-arguments-into-keyword-name
[3] http://code.google.com/p/robotframework/issues/detail?id=375
Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org
More information about the testing-in-python
mailing list