Skip to content

Commit

Permalink
Adds junit as reporter
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrik Sparre Spiegelhauer (HSPU) committed Mar 15, 2024
1 parent ee747a5 commit 62e189b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion tests/testthat.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
library(testthat)
library(ramnog)

test_check("ramnog")
test_check("ramnog", reporter = JunitReporter$new(file = "junit_result.xml"))
60 changes: 32 additions & 28 deletions tests/testthat/binary_type_2.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@ test_that("Binary outcomes of type 2 work", {
# SETUP -------------------------------------------------------------------
testr::create_local_project()

mk_ep_def <- function(){
chef::mk_endpoint_str(
data_prepare = mk_adae,
pop_var = "SAFFL",
pop_value = "Y",
treatment_var = "TRT01A",
treatment_refval = "Xanomeline High Dose",
group_by = list(list(AESOC = c())),
stratify_by = list(c("AEDECOD")),
stat_by_strata_by_trt = list(chefStats::n_subj_event,
chefStats::n_event)
)
}
mk_ep_def <- function() {
chef::mk_endpoint_str(
data_prepare = mk_adae,
pop_var = "SAFFL",
pop_value = "Y",
treatment_var = "TRT01A",
treatment_refval = "Xanomeline High Dose",
group_by = list(list(AESOC = c())),
stratify_by = list(c("AEDECOD")),
stat_by_strata_by_trt = list(
chefStats::n_subj_event,
chefStats::n_event
)
)
}
chef::use_chef(
pipeline_dir = "pipeline",
r_functions_dir = "R/",
Expand All @@ -23,32 +25,34 @@ test_that("Binary outcomes of type 2 work", {
mk_adam_fn = list(mk_adae),
)
# ACT ---------------------------------------------------------------------
browser()
targets::tar_make()
targets::tar_load(ep_stat)

# EXPECT ------------------------------------------------------------------
actual <-
tidyr::unnest(ep_stat[grepl("GASTRO", endpoint_group_filter) |
grepl("CARDIAC", endpoint_group_filter),
.(endpoint_group_filter,
stat_filter,
stat_empty,
fn_name,
stat_result)], cols = stat_result) |>
tidyr::unnest(ep_stat[
grepl("GASTRO", endpoint_group_filter) |
grepl("CARDIAC", endpoint_group_filter),
.(
endpoint_group_filter,
stat_filter,
stat_empty,
fn_name,
stat_result
)
], cols = stat_result) |>
setDT() |>
setorder(-value)

x <- mk_adae()
n <- x[AESOC == "CARDIAC DISORDERS" &
AEDECOD == "SINUS BRADYCARDIA" & TRT01A == "Xanomeline High Dose"] |> uniqueN(by="USUBJID")
AEDECOD == "SINUS BRADYCARDIA" & TRT01A == "Xanomeline High Dose"] |> uniqueN(by = "USUBJID")
E <- x[AESOC == "CARDIAC DISORDERS" &
AEDECOD == "SINUS BRADYCARDIA" & TRT01A == "Xanomeline High Dose"] |> nrow()
AEDECOD == "SINUS BRADYCARDIA" & TRT01A == "Xanomeline High Dose"] |> nrow()

actual_values <- actual[grepl("CARDIAC", endpoint_group_filter) &
grepl("SINUS BRADYCARDIA", stat_filter) &
grepl("Xan", stat_filter)&(label == "n" |
label == "E")][order(label)][,value]
expect_equal(actual_values, c(E, n))

grepl("SINUS BRADYCARDIA", stat_filter) &
grepl("Xan", stat_filter) & (label == "n" |
label == "E")][order(label)][, value]
expect_equal(actual_values, c(E, n))
})
3 changes: 0 additions & 3 deletions tests/testthat/test-binary_type_2.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ test_that("multiplication works", {
stratify_by = list(c("AEDECOD")),
stat_by_strata_by_trt = list(chefStats::p_subj_event)
)

}


Expand All @@ -27,6 +26,4 @@ test_that("multiplication works", {
# ACT ---------------------------------------------------------------------
targets::tar_make()
targets::tar_load(ep_stat)
browser()

})
1 change: 0 additions & 1 deletion vignettes/validation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ test_that("Valide stats when one strata level is not found",
targets::tar_make()
targets::tar_load(ep_stat)
# EXPECT ------------------------------------------------------------------
browser()
x <- mk_adae_demo()
# Relative Risk
actual <-
Expand Down

0 comments on commit 62e189b

Please sign in to comment.