Exam >
On this page

db-show

Shows content of specified database table and creates DbUnit dataset in xml, json or csv formats

Overview

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

attributedescexample
table Table name Required. Default: -
table="androids_table"
cols List of comma-separated column names to include in dataset Optional. Default: -
cols="id, name"
saveToResources Path in srs/test/resources/ where to store generated dataset Optional. Default: -
saveToResources="/data/db/person.xml"
where WHERE clause in database-specific SQL format to filter actual dataset Optional. Default: -
where="name='andrew'"
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
ds="myOtherDatasource"
caption Caption to display instead of table name in report Optional. Default: -
caption="Androids"

Examples

Show empty table

Show empty table

Given


Empty table:
ANDROIDS_TABLE
EMPTY

Then


The following markup:
<e:db-show table="ANDROIDS_TABLE"/>
will be rendered as:
ANDROIDS_TABLE
EMPTY

Show not empty table

Not empty table

Given


ANDROIDS_TABLE
idnameweightheightmanufactured
1Adam101102001-01-01
2Bob201202002-02-02

Then


The following markup:
<e:db-show table="ANDROIDS_TABLE" cols="name, weight, manufactured"/>
will be rendered as:
ANDROIDS_TABLE
NAMEWEIGHTMANUFACTURED
Adam1E+12001-01-01 00:00:00.000
Bob2E+12002-02-02 00:00:00.000

Filtered table

Filtered table

Given


ANDROIDS_TABLE
idnameweightheightmanufactured
1Adam101102001-01-01
2Bob201202002-02-02

Then


The following markup:
<e:db-show table="ANDROIDS_TABLE" cols="name, weight" where="name='Adam'"/>
will be rendered as:
ANDROIDS_TABLE
NAMEWEIGHT
Adam1E+1