User Tools

Site Tools


documentation:software:whiterabbit:test_framework

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
documentation:software:whiterabbit:test_framework [2016/06/03 06:24]
schuemie
documentation:software:whiterabbit:test_framework [2017/12/13 08:23]
schuemie [Test whether the CDM data meets expectations]
Line 73: Line 73:
 ==== 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 ''​%%insertSql%%'',​ and it contains ​the SQL for creating ​the test data. The SQL assumes that the data schema already exists, and will first remove any records that might be in the tables. We can execute the SQL in any SQL client, or we can use OHDSI'​s [[https://​github.com/​OHDSI/​DatabaseConnector|DatabaseConnector package]]. For example:+After we have defined all our tests we need to run  
 +<​code>​ 
 +insertSql ​<- generateInsertSql(databaseSchema = "​nativeTestSchema"​) 
 +testSql <- generateTestSql(databaseSchema = "​cdmTestSchema"​) 
 +</​code>​ 
 +to generate ​the SQL for inserting ​the test data in the database (insertSql),​ and for running the tests on the ETL-ed data (testSql). The insertion ​SQL assumes that the data schema already exists ​in ''​nativeTestSchema''​, and will first remove any records that might be in the tables. We can execute the SQL in any SQL client, or we can use OHDSI'​s [[https://​github.com/​OHDSI/​DatabaseConnector|DatabaseConnector package]]. For example:
  
 <​code>​ <​code>​
Line 83: Line 88:
 connection <- connect(connectionDetails) connection <- connect(connectionDetails)
  
-executeSql(connection,​ "USE source_schema"​) 
 executeSql(connection,​ paste(insertSql,​ collapse = "​\n"​)) executeSql(connection,​ paste(insertSql,​ collapse = "​\n"​))
 </​code>​ </​code>​
Line 93: Line 97:
 ==== Test whether the CDM data meets expectations ==== ==== Test whether the CDM data meets expectations ====
  
-The second variable created by our R script is called ''​%%testSql%%''​. It contains ​SQL that will create a table called ''​%%test_results%%''​ in your CDM schema, and populate it with the results of the tests. (If the table already exists it will first be dropped). Again, we could use any SQL client to run this SQL, or we could use DatabaseConnector:​+The test SQL will create a table called ''​%%test_results%%''​ in ''​cdmTestSchema''​, and populate it with the results of the tests. (If the table already exists it will first be dropped). Again, we could use any SQL client to run this SQL, or we could use DatabaseConnector:​
  
 <​code>​ <​code>​
-executeSql(connection,​ "USE cdm_schema"​) 
 executeSql(connection,​ paste(testSql,​ collapse = "​\n"​)) executeSql(connection,​ paste(testSql,​ collapse = "​\n"​))
 </​code>​ </​code>​
documentation/software/whiterabbit/test_framework.txt · Last modified: 2020/02/18 14:13 by maximmoinat