Skip to content

Commit

Permalink
Merge pull request #39 from Merck/self-contained-tests
Browse files Browse the repository at this point in the history
Make tests self-contained and suppress messages
  • Loading branch information
wangben718 authored Feb 29, 2024
2 parents 2e30d2f + 10c9ac2 commit 5d259dd
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 36 deletions.
8 changes: 0 additions & 8 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
# This file is part of the standard setup for testthat.
# It is recommended that you do not modify it.
#
# Where should you do additional test configuration?
# Learn more about the roles of various files in:
# * https://r-pkgs.org/tests.html
# * https://testthat.r-lib.org/reference/test_package.html#special-files

library(testthat)
library(boxly)

Expand Down
18 changes: 9 additions & 9 deletions tests/testthat/test-independant-testing-prepare_boxly.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

meta <- meta_boxly(
boxly_adsl,
boxly_adlb,
population_term = "apat",
observation_term = "wk12",
observation_subset = AVISITN <= 12 & !is.na(CHG)
)

test_that("Its class is 'outdata'", {
output <- prepare_boxly(meta)
meta <- meta_boxly(
boxly_adsl,
boxly_adlb,
population_term = "apat",
observation_term = "wk12",
observation_subset = AVISITN <= 12 & !is.na(CHG)
)

output <- suppressMessages(prepare_boxly(meta))

expect_equal(class(output), "outdata")
expect_equal(output$population, "apat")
Expand Down
30 changes: 19 additions & 11 deletions tests/testthat/test-independent-testing-boxly.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,17 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

test_that("validation of boxly plot Case 1", {
meta <- meta_boxly(
boxly_adsl,
boxly_adlb,
population_term = "apat",
observation_term = "wk12",
observation_subset = AVISITN <= 12 & !is.na(CHG)
)

meta <- meta_boxly(
boxly_adsl,
boxly_adlb,
population_term = "apat",
observation_term = "wk12",
observation_subset = AVISITN <= 12 & !is.na(CHG)
)

x <- prepare_boxly(meta)
x <- suppressMessages(prepare_boxly(meta))

test_that("validation of boxly plot Case 1", {
y <- boxly(x,
color = c("black", "grey", "red"),
hover_summary_var = c("n", "min", "q1", "median", "mean", "q3", "max"),
Expand Down Expand Up @@ -57,8 +56,17 @@ test_that("validation of boxly plot Case 1", {
expect_equal(baselabel, "Change from Baseline: ")
})


test_that("validation of boxly plot Case 2", {
meta <- meta_boxly(
boxly_adsl,
boxly_adlb,
population_term = "apat",
observation_term = "wk12",
observation_subset = AVISITN <= 12 & !is.na(CHG)
)

x <- suppressMessages(prepare_boxly(meta))

y <- boxly(x,
color = c("green", "yellow", "red"),
hover_summary_var = c("n", "min", "q1", "mean", "q3"),
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-independent-testing-meta_boxly.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

x <- meta_boxly(
boxly_adsl,
boxly_adlb,
population_term = "apat",
observation_term = "wk12",
observation_subset = AVISITN <= 12 & !is.na(CHG)
)

test_that("meta_boxly() structure", {
x <- meta_boxly(
boxly_adsl,
boxly_adlb,
population_term = "apat",
observation_term = "wk12",
observation_subset = AVISITN <= 12 & !is.na(CHG)
)

expect_equal(class(x), "meta_adam")
expect_equal(class(x$data_population), "data.frame")
expect_equal(class(x$data_observation), c("tbl_df", "tbl", "data.frame"))
Expand Down

0 comments on commit 5d259dd

Please sign in to comment.