Monday, January 27, 2020

Database testing using TOSCA

Hi folks,

Working with database using tosca is different experience and I found good article on basics.

Here, mention some key concepts for easy reference.

Interactions with databases are performed via SQL statements.
The test sequence consists of three major steps:
  1. Establishing a database connection
  2. Database operations
  3. Closing the database connection
Steering databases requires the use of specific Modules which are included in the Standard.tcesubset. These Modules are located in the folderStandard modules->TBox XEngines->Database.

Establishing a connection to a database - Module Open Connection
Open Connection can be used to establish a connection to a database. The connection is automatically defined as Current Connectionand is saved as a resource. Optionally, you can set the name of the resource via the parameterConnection name. If a connection already exists under the Connection name resource, no new connection is established. If no value is entered for the parameter Connection name, the value of the parameter DSN is used asConnection name. You can either use the DSNattribute for ODBC databases or theConnection string attribute for SQLite databases. The engine enables you to establish multiple database connections. The connection that was established most recently is always the current connection. Use the Module Current Connection to switch between open connections or to define a new Current Connection.
If you want to access SQLite databases via a connection string, use the ModuleAttributeConnection string. The required drivers are part of the Tricentis Tosca Testsuite standard installation.
Executing SQL statements - Module Run SQL Statement
Module Run SQL Statement can be used to steer data sets of one or more database tables. The engine accesses the database that is defined as Current Connection.
Specify the SQL statement to be executed in the parameter SQL Statement. Use the parameter Result Table to verify or buffer the content of a database table
The TBox Database Engine supports all read-onlyTBox table steering ActionModes. TheActionModes Input and Insert are however not supported.
The following ActionModes can be used to steer columns, rows and cells in tables:
ActionMode
Value
Description
Input
Entering a value
Verify
,
Verifying a value or a property
Constraint
This restricts the search
Buffer
Text->
Buffering the value of a cell
Use the ActionMode Select to select the table.
The following properties can be verified in addition to the general properties:
Property
Description
Available for
ColumnCount
Number of columns in the table
table
RowCount
Number of rows in the table
table
ColumnNumber
Index of the selected column. The value for a header column is 0 and the index for the remaining columns is relative to this column.
column
RowNumber
Index of the selected row. The value for a header row is 0 and the index for the remaining rows is relative to this row.
row
RawColumnNumber
Index of the selected column. It always starts at 1.
column
RawRowNumber
Index of the selected row. It always starts at 1.
row


Changing the connection to databases - Module Current Connection
Use the Module Current Connection to switch between established database connections. If the connection entered in the parameter Connection name exists, this is set as Current Connection.

Closing connections to a database - Module Close Connection
Use the Module Close Connection to close specific database connections. If the connection entered in the parameter Connection name exists, this is closed and the corresponding resource is deleted. If the closed connection was the Current Connection, the value zero is assigned to theCurrent Connection.
Closing the Current Connection may lead to errors when executing other Database EngineTestCases. Use the Modules Open Connection orCurrent Connection to define a new database connection as Current Connection. Any open connections will be closed automatically once theTestCase has been entirely executed.

Expert Module
The Expert Module enables you to handle your database statements via one single Module. The database connection is established via the parameters Connection nameDSNUser ID andPassword. This part of the Expert Modulecorresponds to the Module Open Connection. If you use the Current Connection you need not enter any values for the following parameters: DSN,User ID and Password
Use the parameter SQL Statement to execute SQL statements and verify data sets. The parameter Result Table enables you to steer the actions of your database table queries. For further details on the execution of SQL statements, please refer to Run SQL Statment.
Use the parameter Close Connection to specify whether the Current Connection should be closed or not. The parameter value is by default set to True.

No comments:

Post a Comment