documentation:software:whiterabbit:test_framework
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| documentation:software:whiterabbit:test_framework [2016/06/02 13:34] – schuemie | documentation:software:whiterabbit:test_framework [2020/02/18 14:13] (current) – maximmoinat | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Rabbit-In-a-Hat testing framework ====== | ====== Rabbit-In-a-Hat testing framework ====== | ||
| + | |||
| + | **NOTICE FEB 2020:** the current documentation can be found on Github | ||
| + | http:// | ||
| + | |||
| Rabbit-In-a-Hat can generate a framework for creating a set of [[https:// | Rabbit-In-a-Hat can generate a framework for creating a set of [[https:// | ||
| + | |||
| + | Unit testing assumes that you have your data in source format somewhere in a database. You should already have created an ETL process that will extract from the source database, transform it into CDM format, and load it into a CDM schema. The unit test framework can be used to make sure that your ETL process is doing what it is supposed to do. For this you will need to create a new, empty database with exactly the same structure as your source database, and a new empty database where a test CDM database will live. The framework can be used to insert test data into the empty source schema. You can then run your ETL process on the test data to populate the test CDM database. you can then use the framework to verify that the output of the ETL in the test CDM database is what you'd expect given the test source data. | ||
| ===== Overview ===== | ===== Overview ===== | ||
| Line 71: | Line 77: | ||
| ==== Generate test data in the source data schema ==== | ==== Generate test data in the source data schema ==== | ||
| - | If we run our full R script two variables are created in R. The first variable is '' | + | After we have defined all our tests we need to run |
| + | < | ||
| + | insertSql | ||
| + | testSql <- generateTestSql(databaseSchema = " | ||
| + | </ | ||
| + | to generate | ||
| < | < | ||
| Line 81: | Line 92: | ||
| connection <- connect(connectionDetails) | connection <- connect(connectionDetails) | ||
| - | executeSql(connection, | ||
| executeSql(connection, | executeSql(connection, | ||
| </ | </ | ||
| + | |||
| + | ==== Run your ETL on the test data ==== | ||
| + | |||
| + | Now that the test source data is populated. You can run the ETL process you would like to test. The ETL should transform the data in '' | ||
| + | |||
| + | ==== Test whether the CDM data meets expectations ==== | ||
| + | |||
| + | The test SQL will create a table called '' | ||
| + | |||
| + | < | ||
| + | executeSql(connection, | ||
| + | </ | ||
| + | |||
| + | Aftwerwards, | ||
| + | |||
| + | < | ||
| + | querySql(connection, | ||
| + | </ | ||
| + | |||
| + | Which could return this table: | ||
| + | |||
| + | ^ID | ||
| + | |101 |Person gender mappings | ||
| + | |101 |Person gender mappings | ||
| + | |||
| + | In this case we see there were two expect statements under test 101 (Person gender mappings), and both expectations were met so the test passed. | ||
documentation/software/whiterabbit/test_framework.1464874451.txt.gz · Last modified: by schuemie
