angoca / db2unit

db2unit is a testing framework for IBM DB2 SQL PL
https://angoca.github.io/db2unit/
GNU General Public License v3.0
11 stars 3 forks source link

Test with values from a table #70

Open angoca opened 9 years ago

angoca commented 9 years ago

There could be a second type of tests that receives the values from a table. This allows to reuse the same tests with multiple values.

The test should receive a number as parameter (IN). That is the difference with the other test, the current one, which do not receives any parameter.

The framework will identify the type of test, and if the test receives parameters, it will look for a table with the same name in the same schema (same suite name). Then, it will initialize a global variable with the row number (how? rowid? rid?), and then the framework passes this value to the procedure.

The test procedure will then initialize, and call a function that retrieves the values from a table, via a getNextValue. These getNext should be according to the datatype to retrieve (getNextInt, getNextString, getNextDatatype), and they receive the rownumber as parameter. This is not efficient because the table will be accessed many times, however values tables are not that big. The values returned by these functions will be assigned to local variables in the test proc, and they will be used to call the asserts.

It is responsibility of the developer to create the table with the same name as the procedure. The data types of the columns and order should be the same as the getNext function calls in the tests.

This feature was takes from utPLSQL.

angoca commented 9 years ago

The name of the table that contains the values has the same name of the test. This makes easier the match between tables and tests.

CREATE PROCEDURE TESTS.TEST_MY_TEST() ...@
CREATE TABLE TESTS.TEST_MY_TEST(...)@