From 8259280b992ac94eca77ad59532b304c141f6db0 Mon Sep 17 00:00:00 2001 From: JTPetter <61797391+JTPetter@users.noreply.github.com> Date: Wed, 17 Jul 2024 17:27:30 +0200 Subject: [PATCH] Final unit tests --- .../msaTestRetest/lf1-range-chart-by-part.svg | 94 ++++++++++ .../msaTestRetest/lf1-run-chart-of-parts.svg | 113 ++++++++++++ ...-of-1st-measurement-vs-2nd-measurement.svg | 74 ++++++++ .../lf1-trafficchart-subplot-1.svg | 53 ++++++ .../lf1-trafficchart-subplot-2.svg | 53 ++++++ .../msaTestRetest/wf1-range-chart-by-part.svg | 94 ++++++++++ .../msaTestRetest/wf1-run-chart-of-parts.svg | 113 ++++++++++++ ...-of-1st-measurement-vs-2nd-measurement.svg | 74 ++++++++ .../wf1-traffichart-subplot-1.svg | 53 ++++++ .../wf1-traffichart-subplot-2.svg | 53 ++++++ tests/testthat/test-msaTestRetest.R | 172 ++++++++++++------ 11 files changed, 895 insertions(+), 51 deletions(-) create mode 100644 tests/testthat/_snaps/msaTestRetest/lf1-range-chart-by-part.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/lf1-run-chart-of-parts.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/lf1-scatterplot-of-1st-measurement-vs-2nd-measurement.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/lf1-trafficchart-subplot-1.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/lf1-trafficchart-subplot-2.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/wf1-range-chart-by-part.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/wf1-run-chart-of-parts.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/wf1-scatterplot-of-1st-measurement-vs-2nd-measurement.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/wf1-traffichart-subplot-1.svg create mode 100644 tests/testthat/_snaps/msaTestRetest/wf1-traffichart-subplot-2.svg diff --git a/tests/testthat/_snaps/msaTestRetest/lf1-range-chart-by-part.svg b/tests/testthat/_snaps/msaTestRetest/lf1-range-chart-by-part.svg new file mode 100644 index 00000000..4f0b7964 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/lf1-range-chart-by-part.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +CL = 0.05 + +LCL = 0 + +UCL = 0.16 + + + + + + + + + + + + + + + + + + + + + + +0.00 +0.05 +0.10 +0.15 +0.20 + + + + + + + + + + + + + + + +1 +2 +4 +6 +8 +10 +12 +14 +15 +Sample +Sample range +LF1_range-chart-by-part + + diff --git a/tests/testthat/_snaps/msaTestRetest/lf1-run-chart-of-parts.svg b/tests/testthat/_snaps/msaTestRetest/lf1-run-chart-of-parts.svg new file mode 100644 index 00000000..f7c3020d --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/lf1-run-chart-of-parts.svg @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1.0 +1.1 +1.2 +1.3 +1.4 +1.5 + + + + + + + + + + + + + + + + + + + + + + +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +Part +Measurements +LF1_run-chart-of-parts + + diff --git a/tests/testthat/_snaps/msaTestRetest/lf1-scatterplot-of-1st-measurement-vs-2nd-measurement.svg b/tests/testthat/_snaps/msaTestRetest/lf1-scatterplot-of-1st-measurement-vs-2nd-measurement.svg new file mode 100644 index 00000000..cf759c26 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/lf1-scatterplot-of-1st-measurement-vs-2nd-measurement.svg @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1.0 +1.2 +1.4 +1.6 + + + + + + + + + +1.0 +1.2 +1.4 +1.6 +1 +2 +LF1_scatterplot-of-1st-measurement-vs-2nd-measurement + + diff --git a/tests/testthat/_snaps/msaTestRetest/lf1-trafficchart-subplot-1.svg b/tests/testthat/_snaps/msaTestRetest/lf1-trafficchart-subplot-1.svg new file mode 100644 index 00000000..1c122d87 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/lf1-trafficchart-subplot-1.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +2.17% + + + + + + + + + +0% +10% +30% +100% +Percent study variation of GRR +LF1_trafficChart-subplot-1 + + diff --git a/tests/testthat/_snaps/msaTestRetest/lf1-trafficchart-subplot-2.svg b/tests/testthat/_snaps/msaTestRetest/lf1-trafficchart-subplot-2.svg new file mode 100644 index 00000000..8bc24231 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/lf1-trafficchart-subplot-2.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.52% + + + + + + + + + +0% +10% +30% +100% +Percent tolerance of GRR +LF1_trafficChart-subplot-2 + + diff --git a/tests/testthat/_snaps/msaTestRetest/wf1-range-chart-by-part.svg b/tests/testthat/_snaps/msaTestRetest/wf1-range-chart-by-part.svg new file mode 100644 index 00000000..cafb9161 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/wf1-range-chart-by-part.svg @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +CL = 0.05 + +LCL = 0 + +UCL = 0.16 + + + + + + + + + + + + + + + + + + + + + + +0.00 +0.05 +0.10 +0.15 +0.20 + + + + + + + + + + + + + + + +1 +2 +4 +6 +8 +10 +12 +14 +15 +Sample +Sample range +WF1_range-chart-by-part + + diff --git a/tests/testthat/_snaps/msaTestRetest/wf1-run-chart-of-parts.svg b/tests/testthat/_snaps/msaTestRetest/wf1-run-chart-of-parts.svg new file mode 100644 index 00000000..d6e2f201 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/wf1-run-chart-of-parts.svg @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1.0 +1.1 +1.2 +1.3 +1.4 +1.5 + + + + + + + + + + + + + + + + + + + + + + +1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +Part +Measurements +WF1_run-chart-of-parts + + diff --git a/tests/testthat/_snaps/msaTestRetest/wf1-scatterplot-of-1st-measurement-vs-2nd-measurement.svg b/tests/testthat/_snaps/msaTestRetest/wf1-scatterplot-of-1st-measurement-vs-2nd-measurement.svg new file mode 100644 index 00000000..be5584e6 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/wf1-scatterplot-of-1st-measurement-vs-2nd-measurement.svg @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1.0 +1.2 +1.4 +1.6 + + + + + + + + + +1.0 +1.2 +1.4 +1.6 +Measurement1 +Measurement2 +WF1_scatterplot-of-1st-measurement-vs-2nd-measurement + + diff --git a/tests/testthat/_snaps/msaTestRetest/wf1-traffichart-subplot-1.svg b/tests/testthat/_snaps/msaTestRetest/wf1-traffichart-subplot-1.svg new file mode 100644 index 00000000..e4300fc2 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/wf1-traffichart-subplot-1.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +2.17% + + + + + + + + + +0% +10% +30% +100% +Percent study variation of GRR +WF1_traffiChart-subplot-1 + + diff --git a/tests/testthat/_snaps/msaTestRetest/wf1-traffichart-subplot-2.svg b/tests/testthat/_snaps/msaTestRetest/wf1-traffichart-subplot-2.svg new file mode 100644 index 00000000..46d71840 --- /dev/null +++ b/tests/testthat/_snaps/msaTestRetest/wf1-traffichart-subplot-2.svg @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +0.52% + + + + + + + + + +0% +10% +30% +100% +Percent tolerance of GRR +WF1_traffiChart-subplot-2 + + diff --git a/tests/testthat/test-msaTestRetest.R b/tests/testthat/test-msaTestRetest.R index 01c88b6c..43b9a4a7 100644 --- a/tests/testthat/test-msaTestRetest.R +++ b/tests/testthat/test-msaTestRetest.R @@ -1,51 +1,121 @@ -# context("[Quality Control] MSA Test Retest") -# .numDecimals <-2 -# -# options <- analysisOptions("msaTestRetest") -# options$dataFormat <- "wideFormat" -# options$partWideFormat <- "Part" -# options$measurementsWideFormat <- c("X1", "X2") -# options$manualProcessSd <- TRUE -# options$manualProcessSdValue <- 2 -# options$tolerance <- TRUE -# options$toleranceValue <- 0.5 -# options$repeatabilityAndReproducibilityTable <- TRUE -# options$runChartPart <- TRUE -# options$scatterPlotMeasurement <- TRUE -# options$scatterPlotMeasurementFitLine <- TRUE -# options$rChart <- TRUE -# options$trafficLightChart <- TRUE -# -# results <- runAnalysis("msaTestRetest", "msaTestRetest.csv", options) -# -# test_that("Run chart of parts plot matches", { -# plotName <- results[["results"]][["ScatterOperatorParts"]][["data"]] -# testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] -# jaspTools::expect_equal_plots(testPlot, "run-chart-of-parts") -# }) -# -# test_that("Scatterplot of 1st measurement vs 2nd measurement matches", { -# plotName <- results[["results"]][["ScatterOperators"]][["data"]] -# testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] -# jaspTools::expect_equal_plots(testPlot, "scatterplot-of-1st-measurement-vs-2nd-measurement") -# }) -# -# test_that("Short gauge study table results match", { -# table <- results[["results"]][["rAndR2"]][["data"]] -# jaspTools::expect_equal_tables(table, -# list(0.0434914974122558, 2.17457487061279, 0.52189796894707, 2, 0.0499999999999999, -# 1.14965, 15, 0.5)) -# }) -# -# test_that("Range chart by part plot matches", { -# plotName <- results[["results"]][["rChart"]][["collection"]][["rChart_plot"]][["data"]] -# testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] -# jaspTools::expect_equal_plots(testPlot, "range-chart-by-part") -# }) -# -# test_that("Traffic light chart matches", { -# plotName <- results[["results"]][["trafficPlot"]][["collection"]][["trafficPlot_plot"]][["data"]] -# testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] -# jaspTools::expect_equal_plots(testPlot, "Traffic-light-chart") -# }) -# +context("[Quality Control] MSA Test Retest") +.numDecimals <- 2 + +# Long Format #### + +## Default Settings #### + +options <- analysisOptions("msaTestRetest") +options$dataFormat <- "longFormat" +options$partLongFormat <- "Part" +options$measurementLongFormat <- "Measurement" +options$operator <- "Repetition" +options$manualProcessSd <- TRUE +options$manualProcessSdValue <- 2 +options$tolerance <- TRUE +options$toleranceValue <- 0.5 +options$repeatabilityAndReproducibilityTable <- TRUE +options$runChartPart <- TRUE +options$scatterPlotMeasurement <- TRUE +options$scatterPlotMeasurementFitLine <- TRUE +options$rChart <- TRUE +options$trafficLightChart <- TRUE + +results <- runAnalysis("msaTestRetest", "datasets/msaTestRetest/msaTestRetest_long.csv", options) + +test_that("LF1.1 Default Settings - Run chart of parts plot matches", { + plotName <- results[["results"]][["ScatterOperatorParts"]][["data"]] + testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] + jaspTools::expect_equal_plots(testPlot, "LF1_run-chart-of-parts") +}) + +test_that("LF1.2 Default Settings - Scatterplot of 1st measurement vs 2nd measurement matches", { + plotName <- results[["results"]][["ScatterOperators"]][["data"]] + testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] + jaspTools::expect_equal_plots(testPlot, "LF1_scatterplot-of-1st-measurement-vs-2nd-measurement") +}) + +test_that("LF1.3 Default Settings - Short gauge study table results match", { + table <- results[["results"]][["rAndR2"]][["data"]] + jaspTools::expect_equal_tables(table, + list(0.0434914974122558, 2.17457487061279, 0.52189796894707, 2, 0.0499999999999999, + 1.14965, 15, 0.5)) +}) + +test_that("LF1.4 Default Settings - Range chart by part plot matches", { + plotName <- results[["results"]][["rChart"]][["collection"]][["rChart_plot"]][["data"]] + testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] + jaspTools::expect_equal_plots(testPlot, "LF1_range-chart-by-part") +}) + +test_that("LF1.5 Default Settings - Test results for range chart table results match", { + table <- results[["results"]][["rChart"]][["collection"]][["rChart_table"]][["data"]] + jaspTools::expect_equal_tables(table, + list("No test violations occurred.")) +}) + +test_that("LF1.6 Default Settings - Traffic chart matches", { + plotName <- results[["results"]][["trafficPlot"]][["collection"]][["trafficPlot_plot"]][["data"]] + testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] + jaspTools::expect_equal_plots(testPlot, "LF1_trafficChart") +}) + +# Wide Format #### + +## Default Settings #### + +options <- analysisOptions("msaTestRetest") +options$dataFormat <- "wideFormat" +options$partWideFormat <- "Part" +options$measurementsWideFormat <- c("Measurement1", "Measurement2") +options$manualProcessSd <- TRUE +options$manualProcessSdValue <- 2 +options$tolerance <- TRUE +options$toleranceValue <- 0.5 +options$repeatabilityAndReproducibilityTable <- TRUE +options$runChartPart <- TRUE +options$scatterPlotMeasurement <- TRUE +options$scatterPlotMeasurementFitLine <- TRUE +options$rChart <- TRUE +options$trafficLightChart <- TRUE + +results <- runAnalysis("msaTestRetest", "datasets/msaTestRetest/msaTestRetest_wide.csv", options) + + +test_that("WF1.1 Default Settings - Run chart of parts plot matches", { + plotName <- results[["results"]][["ScatterOperatorParts"]][["data"]] + testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] + jaspTools::expect_equal_plots(testPlot, "WF1_run-chart-of-parts") +}) + +test_that("WF1.2 Default Settings - Scatterplot of 1st measurement vs 2nd measurement matches", { + plotName <- results[["results"]][["ScatterOperators"]][["data"]] + testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] + jaspTools::expect_equal_plots(testPlot, "WF1_scatterplot-of-1st-measurement-vs-2nd-measurement") +}) + +test_that("WF1.3 Default Settings - Short gauge study table results match", { + table <- results[["results"]][["rAndR2"]][["data"]] + jaspTools::expect_equal_tables(table, + list(0.0434914974122558, 2.17457487061279, 0.52189796894707, 2, 0.0499999999999999, + 1.14965, 15, 0.5)) +}) + +test_that("WF1.4 Default Settings - Range chart by part plot matches", { + plotName <- results[["results"]][["rChart"]][["collection"]][["rChart_plot"]][["data"]] + testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] + jaspTools::expect_equal_plots(testPlot, "WF1_range-chart-by-part") +}) + +test_that("WF1.5 Default Settings - Test results for range chart table results match", { + table <- results[["results"]][["rChart"]][["collection"]][["rChart_table"]][["data"]] + jaspTools::expect_equal_tables(table, + list("No test violations occurred.")) +}) + +test_that("WF1.6 Default Settings - Traffic chart matches", { + plotName <- results[["results"]][["trafficPlot"]][["collection"]][["trafficPlot_plot"]][["data"]] + testPlot <- results[["state"]][["figures"]][[plotName]][["obj"]] + jaspTools::expect_equal_plots(testPlot, "WF1_traffiChart") +}) +