From 072ca777b5371977eb56cae9d0b2e4351165a630 Mon Sep 17 00:00:00 2001 From: JTPetter <61797391+JTPetter@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:37:27 +0200 Subject: [PATCH] fix unit tests --- .../{ => datasets/attributeCharts}/SPC_NP.csv | 0 .../{ => datasets/attributeCharts}/SPC_P.csv | 2 +- tests/testthat/test-attributesCharts.R | 14 ++--- tests/testthat/test-doeFactorial.R | 51 +++++++------------ .../test-doeResponseSurfaceMethodology.R | 30 ++++------- 5 files changed, 35 insertions(+), 62 deletions(-) rename tests/testthat/{ => datasets/attributeCharts}/SPC_NP.csv (100%) rename tests/testthat/{ => datasets/attributeCharts}/SPC_P.csv (92%) diff --git a/tests/testthat/SPC_NP.csv b/tests/testthat/datasets/attributeCharts/SPC_NP.csv similarity index 100% rename from tests/testthat/SPC_NP.csv rename to tests/testthat/datasets/attributeCharts/SPC_NP.csv diff --git a/tests/testthat/SPC_P.csv b/tests/testthat/datasets/attributeCharts/SPC_P.csv similarity index 92% rename from tests/testthat/SPC_P.csv rename to tests/testthat/datasets/attributeCharts/SPC_P.csv index 781cdc0b..2fdd999f 100644 --- a/tests/testthat/SPC_P.csv +++ b/tests/testthat/datasets/attributeCharts/SPC_P.csv @@ -1,4 +1,4 @@ -"","ï..Month","Size","D","Proportion" +"","Month","Size","D","Proportion" "1","Sep",150,21,0.14 "2","Oct",153,16,0.105 "3","Nov",170,30,0.176 diff --git a/tests/testthat/test-attributesCharts.R b/tests/testthat/test-attributesCharts.R index dbdb499b..bd10a0e3 100644 --- a/tests/testthat/test-attributesCharts.R +++ b/tests/testthat/test-attributesCharts.R @@ -8,7 +8,7 @@ options$total <- "Size" options$attributesChart <- "defectives" options$attributesChartDefectivesChartType <- "npChart" set.seed(1) -results <- runAnalysis("attributesCharts", "SPC_NP.csv", options) +results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_NP.csv", options) test_that("np Chart plot matches", { plotName <- results[["results"]][["NPchartPlot"]][["data"]] @@ -25,7 +25,7 @@ test_that("Test results for np chart table results match", { # P options$attributesChartDefectivesChartType <- "pChart" -results <- runAnalysis("attributesCharts", "SPC_P.csv", options) +results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options) test_that("p Chart plot matches", { plotName <- results[["results"]][["PchartPlot"]][["data"]] @@ -35,7 +35,7 @@ test_that("p Chart plot matches", { # Laney's P options$attributesChartDefectivesChartType <- "laneyPPrimeChart" -results <- runAnalysis("attributesCharts", "SPC_P.csv", options) +results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options) test_that("Laney p' Chart plot matches", { plotName <- results[["results"]][["LaneyPPlot"]][["data"]] @@ -48,7 +48,7 @@ test_that("Laney p' Chart plot matches", { options$attributesChartDefectivesChartType <- "npChart" options$attributesChart <- "defects" options$attributesChartDefectsChartType <- "cChart" -results <- runAnalysis("attributesCharts", "SPC_NP.csv", options) +results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_NP.csv", options) test_that("c Chart plot matches", { plotName <- results[["results"]][["CchartPlot"]][["data"]] @@ -64,7 +64,7 @@ test_that("Test results for c chart table results match", { # U options$attributesChartDefectsChartType <- "uChart" -results <- runAnalysis("attributesCharts", "SPC_P.csv", options) +results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options) test_that("u Chart plot matches", { plotName <- results[["results"]][["UchartPlot"]][["data"]] @@ -74,7 +74,7 @@ test_that("u Chart plot matches", { # Laneys U options$attributesChartDefectsChartType <- "laneyUPrimeChart" -results <- runAnalysis("attributesCharts", "SPC_P.csv", options) +results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options) test_that("Laney u' Chart plot matches", { plotName <- results[["results"]][["LaneyUPlot"]][["data"]] @@ -84,7 +84,7 @@ test_that("Laney u' Chart plot matches", { ## I MR options$attributesChart <- "xmr" -results <- runAnalysis("attributesCharts", "SPC_P.csv", options) +results <- runAnalysis("attributesCharts", "datasets/attributeCharts/SPC_P.csv", options) test_that("Individuals and Moving Range Chart plot matches", { plotName <- results[["results"]][["IPlotA"]][["data"]] diff --git a/tests/testthat/test-doeFactorial.R b/tests/testthat/test-doeFactorial.R index 7a470032..37a592c4 100644 --- a/tests/testthat/test-doeFactorial.R +++ b/tests/testthat/test-doeFactorial.R @@ -23,8 +23,7 @@ options$selectedDesign2 <- list(list(levels = "Row 0", name = "data 1", values = options$selectedRow <- 0 # select design options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("1.1 Two Factor Two Level Factorial Design table results match", { @@ -59,8 +58,7 @@ options$selectedDesign2 <- list(list(levels = c("Row 0", "Row 1", "Row 2"), name options$selectedRow <- 2 # select design options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("2.1 Five Factor Two Level Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -106,8 +104,7 @@ options$selectedDesign2 <- list(list(levels = c("Row 0", "Row 1", "Row 2"), name options$selectedRow <- 0 # select design options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("3.1 Five Factor Two Level Frac. Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -158,8 +155,7 @@ options$selectedDesign2 <- list(list(levels = c("Row 0", "Row 1", "Row 2", "Row options$selectedRow <- 3 # select design options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("4.1 Nine Factor Two Level Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -288,8 +284,7 @@ options$selectedDesign2 <- list(list(levels = c("Row 0", "Row 1", "Row 2", "Row options$selectedRow <- 0 # select design options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("5.1 Nine Factor Two Level Frac. Factorial Design table results match", { @@ -337,8 +332,7 @@ options$selectedRow <- 1 # select design options$centerpoints <- 1 options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("6.1 One Center Point Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -374,8 +368,7 @@ options$selectedRow <- 1 # select design options$centerpoints <- 2 options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("7.1 Two Center Point Factorial Design table results match", { @@ -412,8 +405,7 @@ options$selectedRow <- 1 # select design options$centerpoints <- 4 options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("8.1 Four Center Point Factorial Design table results match", { @@ -453,8 +445,7 @@ options$selectedRow <- 1 # select design options$blocks <- "2" options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("9.1 Two Blocks Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -490,8 +481,7 @@ options$selectedRow <- 1 # select design options$blocks <- "4" options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("10.1 Four Blocks Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -527,8 +517,7 @@ options$selectedRow <- 1 # select design options$blocks <- "8" options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("11.1 Eight Blocks Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -570,8 +559,7 @@ options$selectedDesign2 <- list(list(levels = "Row 0", name = "data 1", values = options$selectedRow <- 0 # select design options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("12.1 Two Factor One HTC Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -605,8 +593,7 @@ options$selectedDesign2 <- list(list(levels = "Row 0", name = "data 1", values = options$selectedRow <- 1 # select design options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("13.1 Five Factor Two HTC Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -653,8 +640,7 @@ options$selectedDesign2 <- list(list(levels = "Row 0", name = "data 1", values = options$selectedRow <- 1 # select design options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("14.1 Seven Factor Three HTC Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -756,8 +742,7 @@ options$factorialType <- "generalFullFactorial" options$runOrder <- "runOrderStandard" options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("15.1 Three Factor Three Level General Full Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -797,8 +782,7 @@ options$factorialType <- "generalFullFactorial" options$runOrder <- "runOrderStandard" options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("16.1 Three Factor Four Level General Full Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] @@ -842,8 +826,7 @@ options$factorialType <- "generalFullFactorial" options$runOrder <- "runOrderStandard" options$setSeed <- TRUE set.seed(1) -dataset <- NULL -results <- runAnalysis("doeFactorial", dataset, options) +results <- runAnalysis("doeFactorial", "debug.csv", options) test_that("17.1 Four Factor Six Level General Full Factorial Design table results match", { table <- results[["results"]][["displayDesign"]][["data"]] diff --git a/tests/testthat/test-doeResponseSurfaceMethodology.R b/tests/testthat/test-doeResponseSurfaceMethodology.R index f664fb70..f462c073 100644 --- a/tests/testthat/test-doeResponseSurfaceMethodology.R +++ b/tests/testthat/test-doeResponseSurfaceMethodology.R @@ -30,8 +30,7 @@ options$selectedDesign2 <- list( # give design list, always five lists, number o list(levels = c("Row 0", "Row 1"), name = "data 5", values = c(1.682, 1.633)) # alpha ) options$selectedRow <- 1 # select design -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("1.1 Three Cont. Pred. Central Composite Design table results match", { table <- results[["results"]][["designTable"]][["data"]] @@ -79,8 +78,7 @@ options$selectedDesign2 <- list( # give design list, always five lists, number o list(levels = c("Row 0", "Row 1"), name = "data 5", values = c(2.378, 2.366)) # alpha ) options$selectedRow <- 1 # select design -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("2.1 Five Cont. Pred. Central Composite Design table results match", { table <- results[["results"]][["designTable"]][["data"]] @@ -150,8 +148,7 @@ options$selectedDesign2 <- list( # give design list, always five lists, number o list(levels = c("Row 0", "Row 1"), name = "data 5", values = c(1.682, 1.633)) # alpha ) options$selectedRow <- 1 # select design -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("3.1 Three Cont. Pred. Two. Disc. Pred. Central Composite Design table results match", { @@ -239,8 +236,7 @@ options$selectedDesign2 <- list( # give design list, always five lists, number o list(levels = c("Row 0", "Row 1"), name = "data 5", values = c(2, 2)) # alpha ) options$selectedRow <- 1 # select design -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("4.1 Four Cont. Pred. One. Disc. Pred. Central Composite Design table results match", { @@ -310,8 +306,7 @@ options$selectedDesign2 <- list( # give design list, always five lists, number o ) options$selectedRow <- 1 # select design options$alphaType <- "faceCentered" -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("5.1 Three Cont. Pred. Face Centered Central Composite Design table results match", { table <- results[["results"]][["designTable"]][["data"]] @@ -358,8 +353,7 @@ options$selectedDesign2 <- list( # give design list, always five lists, number o ) options$selectedRow <- 1 # select design options$alphaType <- "faceCentered" -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) @@ -414,8 +408,7 @@ options$selectedDesign2 <- list( # give design list, always three lists, number list(levels = c("Row 0"), name = "data 3", values = c(3)) # centre points ) options$selectedRow <- 0 # select design -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("7.1 Three Cont. Pred. Box-Behnken Design table results match", { table <- results[["results"]][["designTable"]][["data"]] @@ -461,8 +454,7 @@ options$selectedDesign2 <- list( # give design list, always three lists, number list(levels = c("Row 0"), name = "data 3", values = c(3)) # centre points ) options$selectedRow <- 0 # select design -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("8.1 Four Cont. Pred. Box-Behnken Design table results match", { @@ -516,8 +508,7 @@ options$selectedDesign2 <- list( # give design list, always three lists, number list(levels = c("Row 0"), name = "data 3", values = c(3)) # centre points ) options$selectedRow <- 0 # select design -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("9.1 Five Cont. Pred. Box-Behnken Design table results match", { table <- results[["results"]][["designTable"]][["data"]] @@ -582,8 +573,7 @@ options$selectedDesign2 <- list( # give design list, always three lists, number list(levels = c("Row 0"), name = "data 3", values = c(6)) # centre points ) options$selectedRow <- 0 # select design -dataset <- NULL -results <- runAnalysis("doeResponseSurfaceMethodology", dataset, options) +results <- runAnalysis("doeResponseSurfaceMethodology", "debug.csv", options) test_that("10.1 Six Cont. Pred. One Disc. Pred. Box-Behnken Design table results match", {