# Following test uses snapshot testing. If expected results changes, the snapshot
# test will fail. To update the new expected result you woll need to accept new
# result by running 'snapshot_accept('get_analysis')'
test_that("main function(get_analysis) test data structure", {
test_result_A <- get_analysis(df_cohort = rwToT_test_file_A,
cohort_name = "Cohort_A",
database_cutoff_date = "2021-04-21")
# Test structure
expect_output(str(test_result_A), "List of 2")
expect_output(str(test_result_A$output_table), "data.frame")
expect_output(str(test_result_A$parametric_km), "data.frame")
# Test parametric output
test_expect_result <- c(48.000, 0.021, 0.011, 0.036)
expect_equal(as.numeric(test_result_A$parametric_km[49, ]),
test_expect_result, tolerance = .03)
#single test to compare all results from output table
expect_snapshot(test_result_A$output_table$Cohort_A)
})
#-------------------------------------------------------------------------------
test_that("get_analysis works using cohort (NSCLC_1L_pembromono)", {
test_result_B <- get_analysis(rwToT::rwToT_test_file_B,
cohort_name = "Cohort_B",
database_cutoff_date = "2021-01-31"
)$output_table$Cohort_B
#single test to compare all output table results
expect_snapshot(test_result_B)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.