handling data with tables

33 views
Skip to first unread message

Matteo Dello Ioio

unread,
Oct 27, 2014, 10:20:59 AM10/27/14
to lettuc...@googlegroups.com
Hi,
   I was reading this tutorial http://lettuce.it/tutorial/tables.html#tutorial-tables, but I have some problem with data types.

Below my feature:

Feature: Search books
Books should be searchable by title, authors or isbn code
Search results should provide the list of books

Scenario: Search by title
Given I have the following books in my database:
| id         | isbn         | title                 | price |
| 1 | 978-0747558194 | Harry Potter and the philosopher's stone | 20.0 |
| 2 | 978-0048232298 | The Lord of the Rings | 16    |
When I search for Potter
Then I should see the following books:
| id         | isbn         | title         | price |
| 1 | 978-0747558194 | Harry Potter and the philosopher's stone | 20.0 |


My problem raise when I try to compare dictionaries (the first from feature and the second one from database).
In short terms when I compare these two dictionaries assertion fail because id and price does not match.
Data from feature table are pure strings while data from database are numbers.

How can I solve this?


Thanks in advance.

Suller Andras

unread,
Oct 27, 2014, 10:09:46 PM10/27/14
to lettuc...@googlegroups.com
Hi Matteo,

I think it is a technical constraint that everything in the data table
is stored as string. You need to do the type conversion in your test,
for example with the int() or float() functions.
If you need more specific help, please show your source code for the
"I should see the following books" step.

Regards,
Andras
> --
> You received this message because you are subscribed to the Google Groups
> "Lettuce Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to lettuce-user...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Matteo Dello Ioio

unread,
Nov 10, 2014, 5:59:24 AM11/10/14
to lettuc...@googlegroups.com
Thank you Andras,
I understand the constraint. I see it's the same on other testing frameworks.
Reply all
Reply to author
Forward
0 new messages