Skip to content

Commit

Permalink
Merge pull request #16 from poissonconsulting/covr-tests
Browse files Browse the repository at this point in the history
fixes #15 getting covr to run by skipping tests
  • Loading branch information
aylapear authored Mar 18, 2024
2 parents 5e17ae9 + 89c8942 commit e733b97
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/testthat/test-predict-growth.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ test_that("bb_predict_growth estimate works", {
})

test_that("bb_predict_growth multiple years each and one year common", {
skip_on_covr()

survival <- bboudata::bbousurv_a
survival <- survival[survival$Year %in% 2002:2003, ]

Expand All @@ -44,6 +46,8 @@ test_that("bb_predict_growth multiple years each and one year common", {
})

test_that("bb_predict_growth 1 year each and no years common", {
skip_on_covr()

survival <- bboudata::bbousurv_a
survival <- survival[survival$Year %in% c(2002, 2004), ]

Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test-zzzfit-recruitment-ml.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
test_that("recruitment default works", {
skip_on_ci()
skip_on_covr()

x <- bboudata::bbourecruit_a
fit <- bb_fit_recruitment_ml(
data = x,
Expand All @@ -16,6 +18,8 @@ test_that("recruitment default works", {

test_that("recruitment fixed year works", {
skip_on_ci()
skip_on_covr()

x <- bboudata::bbourecruit_a
fit <- bb_fit_recruitment_ml(
data = x,
Expand All @@ -33,6 +37,8 @@ test_that("recruitment fixed year works", {

test_that("can change fixed adult_female_proportion", {
skip_on_ci()
skip_on_covr()

x <- bboudata::bbourecruit_a
fit <- bb_fit_recruitment_ml(
data = x,
Expand All @@ -50,6 +56,8 @@ test_that("can change fixed adult_female_proportion", {

test_that("can change fixed yearling_female_proportion", {
skip_on_ci()
skip_on_covr()

x <- bboudata::bbourecruit_a
x$Yearlings[5:10] <- 1
fit <- bb_fit_recruitment_ml(
Expand All @@ -69,6 +77,8 @@ test_that("can change fixed yearling_female_proportion", {
test_that("can estimate adult_female_proportion", {
# minor number rounding differences in fixed year estimates
skip_on_ci()
skip_on_covr()

x <- bboudata::bbourecruit_a
fit <- bb_fit_recruitment_ml(
data = x,
Expand All @@ -86,6 +96,8 @@ test_that("can estimate adult_female_proportion", {

test_that("can set inits", {
skip_on_ci()
skip_on_covr()

x <- bboudata::bbourecruit_a

inits <- list(
Expand Down
20 changes: 20 additions & 0 deletions tests/testthat/test-zzzfit-recruitment.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test_that("recruitment default works", {
skip_on_covr()

x <- bboudata::bbourecruit_a
set.seed(101)
fit <- bb_fit_recruitment(
Expand All @@ -16,6 +18,8 @@ test_that("recruitment default works", {
})

test_that("recruitment can set caribou year", {
skip_on_covr()

x <- bboudata::bbourecruit_a
set.seed(101)
fit <- bb_fit_recruitment(
Expand All @@ -33,6 +37,8 @@ test_that("recruitment can set caribou year", {
})

test_that("recruitment fixed works", {
skip_on_covr()

x <- bboudata::bbourecruit_a
set.seed(101)
fit <- bb_fit_recruitment(
Expand All @@ -51,6 +57,8 @@ test_that("recruitment fixed works", {
})

test_that("recruitment trend works", {
skip_on_covr()

x <- bboudata::bbourecruit_a
set.seed(101)
fit <- bb_fit_recruitment(
Expand All @@ -70,6 +78,8 @@ test_that("recruitment trend works", {
})

test_that("can change fixed adult_female_proportion", {
skip_on_covr()

x <- bboudata::bbourecruit_a
set.seed(101)
fit <- bb_fit_recruitment(
Expand All @@ -88,6 +98,8 @@ test_that("can change fixed adult_female_proportion", {
})

test_that("can estimate adult_female_proportion", {
skip_on_covr()

x <- bboudata::bbourecruit_a
set.seed(101)
fit <- bb_fit_recruitment(
Expand All @@ -106,6 +118,8 @@ test_that("can estimate adult_female_proportion", {
})

test_that("can change fixed yearling_female_proportion", {
skip_on_covr()

x <- bboudata::bbourecruit_a
x$Yearlings[5:10] <- 1
set.seed(101)
Expand All @@ -125,6 +139,8 @@ test_that("can change fixed yearling_female_proportion", {
})

test_that("can set priors", {
skip_on_covr()

x <- bboudata::bbourecruit_a
set.seed(101)

Expand Down Expand Up @@ -162,6 +178,8 @@ test_that("can set priors", {
})

test_that("fails with wrong prior", {
skip_on_covr()

x <- bboudata::bbourecruit_a
wrong_prior <- list(bInterce = 1)
expect_chk_error(bb_fit_recruitment(x, nthin = 1L, priors = wrong_prior, quiet = TRUE), "Names in `priors` must match 'adult_female_proportion_alpha', 'adult_female_proportion_beta', 'b0_mu', 'b0_sd', 'bAnnual_sd', 'bYear_mu', 'bYear_sd' or 'sAnnual_rate', not 'bInterce'.")
Expand All @@ -173,6 +191,8 @@ test_that("fails with multiple populations", {
})

test_that("can set niters", {
skip_on_covr()

x <- bboudata::bbourecruit_a
set.seed(101)
fit <- bb_fit_recruitment(
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/test-zzzfit-survival-ml.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test_that("survival default works", {
skip_on_covr()

x <- bboudata::bbousurv_a
fit <- bb_fit_survival_ml(
data = x,
Expand All @@ -15,6 +17,8 @@ test_that("survival default works", {

test_that("survival fixed works", {
skip_on_ci()
skip_on_covr()

x <- bboudata::bbousurv_a

fit <- bb_fit_survival_ml(
Expand All @@ -32,6 +36,8 @@ test_that("survival fixed works", {
})

test_that("can exclude year effect", {
skip_on_covr()

x <- bboudata::bbousurv_a
fit <- bb_fit_survival_ml(
data = x,
Expand All @@ -49,6 +55,8 @@ test_that("can exclude year effect", {
})

test_that("year trend works", {
skip_on_covr()

x <- bboudata::bbousurv_a
fit <- bb_fit_survival_ml(
data = x,
Expand All @@ -66,6 +74,8 @@ test_that("year trend works", {
})

test_that("year trend only works", {
skip_on_covr()

x <- bboudata::bbousurv_a
fit <- bb_fit_survival_ml(
data = x,
Expand All @@ -85,6 +95,8 @@ test_that("year trend only works", {
test_that("can include_uncertain_morts", {
# produces NaN se for some terms
skip_on_ci()
skip_on_covr()

x <- bboudata::bbousurv_a
x$MortalitiesUncertain <- pmin(x$StartTotal - x$MortalitiesCertain, rbinom(nrow(x), prob = 0.1, size = 1))
fit <- bb_fit_survival_ml(
Expand All @@ -102,6 +114,8 @@ test_that("can include_uncertain_morts", {
})

test_that("can set inits", {
skip_on_covr()

x <- bboudata::bbousurv_a

inits <- list(
Expand Down Expand Up @@ -130,6 +144,8 @@ test_that("fails with multiple populations", {
})

test_that("works with less than 12 months", {
skip_on_covr()

x <- bboudata::bbousurv_c
x <- x[!x$Month %in% 12, ]
fit <- bb_fit_survival_ml(
Expand Down
18 changes: 18 additions & 0 deletions tests/testthat/test-zzzfit-survival.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
test_that("survival default works", {
skip_on_covr()

x <- bboudata::bbousurv_a
set.seed(101)
fit <- bb_fit_survival(
Expand All @@ -15,6 +17,8 @@ test_that("survival default works", {
})

test_that("survival year start works", {
skip_on_covr()

x <- bboudata::bbousurv_a
set.seed(101)
fit <- bb_fit_survival(
Expand All @@ -35,6 +39,8 @@ test_that("survival year start works", {
})

test_that("survival fixed works", {
skip_on_covr()

x <- bboudata::bbousurv_a
set.seed(101)
fit <- bb_fit_survival(
Expand All @@ -53,6 +59,8 @@ test_that("survival fixed works", {
})

test_that("survival year trend + random works", {
skip_on_covr()

x <- bboudata::bbousurv_a
set.seed(101)
fit <- bb_fit_survival(
Expand All @@ -71,6 +79,8 @@ test_that("survival year trend + random works", {
})

test_that("survival year trend only", {
skip_on_covr()

x <- bboudata::bbousurv_a
set.seed(101)
fit <- bb_fit_survival(
Expand All @@ -89,6 +99,8 @@ test_that("survival year trend only", {
})

test_that("can include_uncertain_morts", {
skip_on_covr()

x <- bboudata::bbousurv_a
set.seed(101)
x$MortalitiesUncertain <- pmin(x$StartTotal - x$MortalitiesCertain, rbinom(nrow(x), prob = 0.1, size = 1))
Expand All @@ -107,6 +119,8 @@ test_that("can include_uncertain_morts", {
})

test_that("can set priors", {
skip_on_covr()

x <- bboudata::bbousurv_a
set.seed(101)
priors <- c(b0_mu = 10, b0_sd = 0.5)
Expand Down Expand Up @@ -145,6 +159,8 @@ test_that("fails with multiple populations", {
})

test_that("can set niters", {
skip_on_covr()

x <- bboudata::bbousurv_a
set.seed(101)
fit <- bb_fit_survival(
Expand All @@ -165,6 +181,8 @@ test_that("can set niters", {


test_that("works with less than 12 months", {
skip_on_covr()

x <- bboudata::bbousurv_c
x <- x[!x$Month %in% 12, ]
set.seed(101)
Expand Down

0 comments on commit e733b97

Please sign in to comment.