Database Plugin - Macros - Assert DbUnit¶
Contents :
- # ASSERT_DBUNIT TARGET {database} CONTAINS {dataset}
- # ASSERT_DBUNIT TARGET {database} CONTAINS {dataset} WITH CONFIG {config}
- # ASSERT_DBUNIT TARGET {database} CONTAINS {dataset} WITH FILTER {filter}
- # ASSERT_DBUNIT TARGET {database} CONTAINS {dataset} WITH CONFIG {config} AND FILTER {filter}
- # ASSERT_DBUNIT TARGET {database} EQUALS {dataset}
- # ASSERT_DBUNIT TARGET {database} EQUALS {dataset} WITH CONFIG {config}
- # ASSERT_DBUNIT TARGET {database} EQUALS {dataset} WITH FILTER {filter}
- # ASSERT_DBUNIT TARGET {database} EQUALS {dataset} WITH CONFIG {config} AND FILTER {filter}
# ASSERT_DBUNIT TARGET {database} CONTAINS {dataset}¶
What ?
This macro will check that all the data listed in the ‘dataset file’ exist in the ‘database’. For differences between ASSERT and VERIFY assertion mode see this page.
Underlying instructions :
EXECUTE get.all WITH $() ON {database} AS __actual_{%%rand1}.dbu
LOAD {dataset} AS __temp{%%rand2}.file
CONVERT __temp{%%rand2}.file TO file(param.relativedate) AS __temp_{%%rand3}.file
CONVERT __temp_{%%rand3}.file TO xml(structured) AS __temp_{%%rand4}.xml
CONVERT __temp_{%%rand4}.xml TO dataset.dbunit(dataset) AS __expected_{%%rand5}.dbu
ASSERT __actual_{%%rand1}.dbu DOES contain THE __expected_{%%rand5}.dbu
> Input :
{database}
: The name (in the context) of the database to use (database
type target).{dataset}
: A flat xml dbunit dataset file.
Note :
- If the file designed by
{dataset}
contains formulas of date calculation (See the converter From file to file via param.relativedate), those ones are calculated and replaced by the value. - No need to put all tables.
- No need to put all lines of specified tables.
- No need to put all columns of specified tables.
Example :
# ASSERT_DBUNIT TARGET my_database CONTAINS path/to/my_dataset.xml Database overview :
We add a new employee in dataset who does not exist in database :
SKF script :
We obtain the following error :
We delete the new employee from the dataset :
The assertion is true and you should obtain a build success.
# ASSERT_DBUNIT TARGET {database} CONTAINS {dataset} WITH CONFIG {config}¶
What ?
This macro will check that all the data listed in the ‘dataset file’ exist in the ‘database’ using a DbUnit configuration file. For differences between ASSERT and VERIFY assertion mode see this page.
Underlying instructions :
LOAD {config} AS __temp{config}{%%rand1}.file
CONVERT __temp{config}{%%rand1}.file TO conf.dbunit AS __temp{config}{%%rand2}.conf
EXECUTE get.all WITH $() ON {database} USING __temp{config}{%%rand2}.conf AS __actual_{%%rand3}.dbu
LOAD {dataset} AS __temp{%%rand4}.file
CONVERT __temp{%%rand4}.file TO file(param.relativedate) AS __temp_{%%rand5}.file
CONVERT __temp_{%%rand5}.file TO xml(structured) AS __temp_{%%rand6}.xml
CONVERT __temp_{%%rand6}.xml TO dataset.dbunit(dataset) AS __expected_{%%rand7}.dbu
ASSERT __actual_{%%rand3}.dbu DOES contain THE __expected_{%%rand7}.dbu
> Input :
{database}
: The name (in the context) of the database to use (database
type target).{dataset}
: A flat xml dbunit dataset file.{config}
: A configuration file for DbUnit (‘.properties’).
Note :
- If the file designed by
{dataset}
contains formulas of date calculation (See the converter From file to file via param.relativedate), those ones are calculated and replaced by the value. - No need to put all tables.
- No need to put all lines of specified tables.
- No need to put all columns of specified tables.
Example :
# ASSERT_DBUNIT TARGET my_database CONTAINS path/to/my_dataset.xml WITH CONFIG path/to/my_config_dbunit.properties |
# ASSERT_DBUNIT TARGET {database} CONTAINS {dataset} WITH FILTER {filter}¶
What ?
This macro will check that all the data listed in the ‘dataset file’ exist in the ‘database’ using a DbUnit filter. For differences between ASSERT and VERIFY assertion mode see this page.
Underlying instructions :
LOAD {dataset} AS __temp{%%rand2}.file
CONVERT __temp{%%rand2}.file TO file(param.relativedate) AS __temp_{%%rand3}.file
CONVERT __temp_{%%rand3}.file TO xml(structured) AS __temp_{%%rand4}.xml
CONVERT __temp_{%%rand4}.xml TO dataset.dbunit(dataset) AS __expected_{%%rand5}.dbu
LOAD {filter} AS __filter_{%%rand6}.file
CONVERT __filter_{%%rand6}.file TO filter.dbunit(filter) AS __filter_{%%rand7}.filter
ASSERT __actual_{%%rand1}.dbu DOES contain THE __expected_{%%rand5}.dbu USING __filter_{%%rand7}.filter
> Input :
{database}
: The name (in the context) of the database to use (database
type target).{dataset}
: A flat xml dbunit dataset file.{filter}
: A Dbunit filter ( filter.dbunit SKF resource).
Remark : If the file designed by {dataset}
contains formulas of date calculation (See the converter From file to file via param.relativedate), those ones are calculated and replaced by the value.
Example :
# ASSERT_DBUNIT TARGET my_database CONTAINS path/to/my_dataset.xml WITH FILTER path/to/my_dbunit_filter.xml |
# ASSERT_DBUNIT TARGET {database} CONTAINS {dataset} WITH CONFIG {config} AND FILTER {filter}¶
What ?
This macro will check that all the data listed in the ‘dataset file’ exist in the ‘database’ using a DbUnit configuration file and a DbUnit filter. For differences between ASSERT and VERIFY assertion mode see this page.
Underlying instructions :
LOAD {config} AS __temp{config}{%%rand1}.file
CONVERT __temp{config}{%%rand1}.file TO conf.dbunit AS __temp{config}{%%rand2}.conf
EXECUTE get.all WITH $() ON {database} USING __temp{config}{%%rand2}.conf AS __actual_{%%rand3}.dbu
LOAD {dataset} AS __temp{%%rand4}.file
CONVERT __temp{%%rand4}.file TO file(param.relativedate) AS __temp_{%%rand5}.file
CONVERT __temp_{%%rand5}.file TO xml(structured) AS __temp_{%%rand6}.xml
CONVERT __temp_{%%rand6}.xml TO dataset.dbunit(dataset) AS __expected_{%%rand7}.dbu
LOAD {filter} AS __filter_{%%rand8}.file
CONVERT __filter_{%%rand8}.file TO filter.dbunit(filter) AS __filter_{%%rand9}.filter
ASSERT __actual_{%%rand3}.dbu DOES contain THE __expected_{%%rand7}.dbu USING __filter_{%%rand9}.filter
> Input :
{database}
: The name (in the context) of the database to use (database
type target).{dataset}
: A flat xml dbunit dataset.{config}
: A configuration file for DbUnit (‘.properties’). It should be a ‘conf.dbunit’ SKF resource.{filter}
: A Dbunit filter xml file. It should be a ‘filter.dbunit’ SKF resource.
Remark : If the file designed by {dataset}
contains formulas of date calculation (See the converter From file to file via param.relativedate), those ones are calculated and replaced by the value.
Example :
# ASSERT_DBUNIT TARGET my_database CONTAINS path/to/my_dataset.xml WITH CONFIG path/to/my_dbunit_config.properties AND FILTER path/to/my_dbunit_filter.xml |
# ASSERT_DBUNIT TARGET {database} EQUALS {dataset}¶
What ?
This macro will check that all the data listed in the ‘dataset file’ exist in the ‘database’ and the reverse. For differences between ASSERT and VERIFY assertion mode see this page.
Underlying instructions :
EXECUTE get.all WITH $() ON {database} AS __actual_{%%rand1}.dbu
LOAD {dataset} AS __temp{%%rand2}.file
CONVERT __temp{%%rand2}.file TO file(param.relativedate) AS __temp_{%%rand3}.file
CONVERT __temp_{%%rand3}.file TO xml(structured) AS __temp_{%%rand4}.xml
CONVERT __temp_{%%rand4}.xml TO dataset.dbunit(dataset) AS __expected_{%%rand5}.dbu
ASSERT __actual_{%%rand1}.dbu IS equal THE __expected_{%%rand5}.dbu
> Input :
{database}
: The name (in the context) of the database to use (database
type target).{dataset}
: A flat xml dbunit dataset file.
Remark : If the file designed by {dataset}
contains formulas of date calculation (See the converter From file to file via param.relativedate), those ones are calculated and replaced by the value.
Example :
# ASSERT_DBUNIT TARGET my_database EQUALS path/to/my_dataset.xml Database overview :
We use a dataset containing less employees than the database :
SKF script :
We obtain the following error :
We use a dataset containing exactly all the employees :
We execute the SKF script with the new dataset :
The assertion is true and you should obtain a build success.
# ASSERT_DBUNIT TARGET {database} EQUALS {dataset} WITH CONFIG {config}¶
What ?
This macro will check that all the data listed in the ‘dataset file’ exist in the ‘database’ and the reverse using a DbUnit configuration file. For differences between ASSERT and VERIFY assertion mode see this page.
Underlying instructions :
LOAD {config} AS __temp{config}{%%rand1}.file
CONVERT __temp{config}{%%rand1}.file TO conf.dbunit AS __temp{config}{%%rand2}.conf
EXECUTE get.all WITH $() ON {database} USING __temp{config}{%%rand2}.conf AS __actual_{%%rand3}.dbu
LOAD {dataset} AS __temp{%%rand4}.file
CONVERT __temp{%%rand4}.file TO file(param.relativedate) AS __temp_{%%rand5}.file
CONVERT __temp_{%%rand5}.file TO xml(structured) AS __temp_{%%rand6}.xml
CONVERT __temp_{%%rand6}.xml TO dataset.dbunit(dataset) AS __expected_{%%rand7}.dbu
ASSERT __actual_{%%rand3}.dbu IS equal THE __expected_{%%rand7}.dbu
> Input :
{database}
: The name (in the context) of the database to use (database
type target).{dataset}
: A flat xml dbunit dataset file.{config}
: A configuration file for DbUnit (‘.properties’).
Remark : If the file designed by {dataset}
contains formulas of date calculation (See the converter From file to file via param.relativedate), those ones are calculated and replaced by the value.
Example :
# ASSERT_DBUNIT TARGET my_database EQUALS path/to/my_dataset.xml WITH CONFIG path/to/my_config_dbunit.properties |
# ASSERT_DBUNIT TARGET {database} EQUALS {dataset} WITH FILTER {filter}¶
What ?
This macro will check that all the data listed in the ‘dataset file’ exist in the ‘database’ and the reverse using a DbUnit filter. For differences between ASSERT and VERIFY assertion mode see this page.
Underlying instructions :
EXECUTE get.all WITH $() ON {database} AS __actual_{%%rand1}.dbu
LOAD {dataset} AS __temp{%%rand2}.file
CONVERT __temp{%%rand2}.file TO file(param.relativedate) AS __temp_{%%rand3}.file
CONVERT __temp_{%%rand3}.file TO xml(structured) AS __temp_{%%rand4}.xml
CONVERT __temp_{%%rand4}.xml TO dataset.dbunit(dataset) AS __expected_{%%rand5}.dbu
LOAD {filter} AS __filter_{%%rand6}.file
CONVERT __filter_{%%rand6}.file TO filter.dbunit(filter) AS __filter_{%%rand7}.filter
ASSERT __actual_{%%rand1}.dbu IS equal THE __expected_{%%rand5}.dbu USING __filter_{%%rand7}.filter
> Input :
{database}
: The name (in the context) of the database to use (database
type target).{dataset}
: A flat xml dbunit dataset file.{filter}
: A DbUnit filter xml file. It should be a ‘filter.dbunit’ SKF resource.
Remark : If the file designed by {dataset}
contains formulas of date calculation (See the converter From file to file via param.relativedate), those ones are calculated and replaced by the value.
Example :
# ASSERT_DBUNIT TARGET my_database EQUALS path/to/my_dataset.xml WITH FILTER path/to/my_dbunit_filter.xml |
# ASSERT_DBUNIT TARGET {database} EQUALS {dataset} WITH CONFIG {config} AND FILTER {filter}¶
What ?
This macro will check that all the data listed in the ‘dataset file’ exist in the ‘database’ and the reverse using a DbUnit configuration file and a DbUnit filter. For differences between ASSERT and VERIFY assertion mode see this page.
Underlying instructions :
LOAD {config} AS __temp{config}{%%rand1}.file
CONVERT __temp{config}{%%rand1}.file TO conf.dbunit AS __temp{config}{%%rand2}.conf
EXECUTE get.all WITH $() ON {database} USING __temp{config}{%%rand2}.conf AS __actual_{%%rand3}.dbu
LOAD {dataset} AS __temp{%%rand4}.file
CONVERT __temp{%%rand4}.file TO file(param.relativedate) AS __temp_{%%rand5}.file
CONVERT __temp_{%%rand5}.file TO xml(structured) AS __temp_{%%rand6}.xml
CONVERT __temp_{%%rand6}.xml TO dataset.dbunit(dataset) AS __expected_{%%rand7}.dbu
LOAD {filter} AS __filter_{%%rand8}.file
CONVERT __filter_{%%rand8}.file TO filter.dbunit(filter) AS __filter_{%%rand9}.filter
ASSERT __actual_{%%rand3}.dbu IS equal THE __expected_{%%rand7}.dbu USING __filter_{%%rand9}.filter
> Input :
{database}
: The name (in the context) of the database to use (database
type target).{dataset}
: A flat xml dbunit dataset file.{config}
: A configuration file for DbUnit (‘.properties’). It should be a ‘conf.dbunit’ SKF resource.{filter}
: A DbUnit filter xml file. It should be a ‘filter.dbunit’ SKF resource.
Remark : If the file designed by {dataset}
contains formulas of date calculation (See the converter From file to file via param.relativedate), those ones are calculated and replaced by the value.
Example :
# ASSERT_DBUNIT TARGET my_database EQUALS path/to/my_dataset.xml WITH CONFIG path/to/my_dbunit_config.properties AND FILTER path/to/my_dbunit_filter.xml |