db-show
Shows content of specified database table and creates DbUnit dataset in xml, json or csv formats
Overview
e:db-show
<e:db-show table="ANDROIDS_TABLE"/>
Usage
1. Configure a connection to database via DbPlugin.
2. Use e:db-show
tag in specification:
src/test/resources/specs/Specs.html
<e:db-show table="ANDROIDS_TABLE"/>
Attributes
attribute | desc | example |
---|---|---|
table |
Table name | Required. Default: -
|
cols |
List of comma-separated column names to include in dataset | Optional. Default: -
|
saveToResources |
Path in srs/test/resources/ where to store generated dataset |
Optional. Default: -
|
where |
WHERE clause in database-specific SQL format to filter actual dataset | Optional. Default: -
|
ds |
Datasource to which dataset will be applied. By default only 1 datasource with name default exists, other may be added by DbPlugin configuration. | Optional. Default: default
|
caption |
Caption to display instead of table name in report | Optional. Default: -
|
Examples
Show empty table
Given
Empty table:
EMPTY |
Then
The following markup:
<e:db-show table="ANDROIDS_TABLE"/>
will be rendered as:EMPTY |
Show not empty table
Given
id | name | weight | height | manufactured |
---|---|---|---|---|
1 | Adam | 10 | 110 | 2001-01-01 |
2 | Bob | 20 | 120 | 2002-02-02 |
Then
The following markup:
<e:db-show table="ANDROIDS_TABLE" cols="name, weight, manufactured"/>
will be rendered as:NAME | WEIGHT | MANUFACTURED |
---|---|---|
Adam | 1E+1 | 2001-01-01 00:00:00.000 |
Bob | 2E+1 | 2002-02-02 00:00:00.000 |
Filtered table
Given
id | name | weight | height | manufactured |
---|---|---|---|---|
1 | Adam | 10 | 110 | 2001-01-01 |
2 | Bob | 20 | 120 | 2002-02-02 |
Then
The following markup:
<e:db-show table="ANDROIDS_TABLE" cols="name, weight" where="name='Adam'"/>
will be rendered as:NAME | WEIGHT |
---|---|
Adam | 1E+1 |