Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pilot unit test refactor for AE_Map_Raw + workflow template #337

Merged
merged 9 commits into from
Apr 5, 2022

Conversation

mattroumaya
Copy link
Contributor

Overview

  • Pilot refactor based on discussion Refactoring unit tests #335
  • Added utility function use_gsm_test(), modeled after this {usethis} example
  • Implemented expect_snapshot_error which captures all warning messages in .md files in tests/testthat/_snaps.
    • If we go this route, the tests will fail if the error message ever changes

Test Notes/Sample Code

  • Utility function code below. If working correctly, this should bring up a skeleton .R file that can be resaved as a new test file.
use_gsm_test("map")
use_gsm_test("assess")

Risk Assessment

Risk: Low
Mitigation Strategy:

  • Qualification Testing - N/A
  • Unit Testing - Included
  • Code Review - Included via PR review
  • QC Checklist - To be included with Release
  • Automated Testing - Package Checks via GitHub Actions

@mattroumaya mattroumaya requested a review from jwildfire March 30, 2022 15:57
Merge branch 'dev' of github.com:Gilead-BioStats/gsm into unit-tests

# Conflicts:
#	tests/testthat/test_AE_Map_Raw.R
R/utils-testSkeleton.R Outdated Show resolved Hide resolved

# 1. output created as expected -------------------------------------------
test_that("output created as expected", {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we could fill in defaults here, no?

input2 <- "dfY here"

expect_snapshot_error(
X_Map_Raw(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe in PREP we did a something {assessment}_Map_Raw and then did a find/replace via grep.

Maybe add an assesssment parameter to use_gsm_test and then automatically update.

)
)

expect_snapshot_error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can demo this for me at some point. I'm on the fence about whether it's needed.

tests/testthat/test_AE_Map_Raw.R Outdated Show resolved Hide resolved
expect_error(AE_Map_Raw(list(), dfRDSL)%>%suppressMessages,"Errors found in dfAE.")
expect_error(AE_Map_Raw("Hi", "Mom")%>%suppressMessages,"Errors found in dfAE.")
expect_error(AE_Map_Raw(dfAE, dfRDSL, mapping = list())%>%suppressMessages,"Errors found in dfAE.")
expect_snapshot_error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also interested in how this will work on Github Actions ...

tests/testthat/test_AE_Map_Raw.R Show resolved Hide resolved
tests/testthat/test_AE_Map_Raw.R Outdated Show resolved Hide resolved
@jwildfire
Copy link
Contributor

One other thought is that I wonder if we should limit the unit tests to synthetic data (set up in tribbles) and then just have the QC tests use clindata. That would somewhat simplify our pipeline to open source and (I think) make the unit tests much more stable and maintainable.

@mattroumaya
Copy link
Contributor Author

mattroumaya commented Mar 31, 2022

This still needs some work but the general idea should work by pulling this branch and running

use_gsm_test(“ae_map”)

@mattroumaya mattroumaya requested a review from jwildfire April 4, 2022 15:14
@mattroumaya
Copy link
Contributor Author

@jwildfire I think this is in a good place for you to review again and make sure it's shaping up how you'd like. Definitely happy to do a quick demo after scrum or some other convenient time

@mattroumaya mattroumaya self-assigned this Apr 4, 2022
@mattroumaya mattroumaya merged commit 43a2a2c into dev Apr 5, 2022
@mattroumaya mattroumaya deleted the unit-tests branch April 12, 2022 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants