alteryx / alteryx/AlteryxPrescriptive
Write a testFactory function.
- Vorherrschende Sprache
- R
- Sterne
- 3
- Forks
- 5
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
The test code can be refactored considerably by refactoring common elements into a `testFactory` function. Here is a crude example.
``` r
config <- list(inputMode = 'file', problemType = 'lp')
payload <- list(config = config, inputs = NULL)
createTestGrid <- function(filePaths, solvers){
expand.grid(filePath = filePaths, solver = solvers)
}
testGrid <- createTestGrid(
filePaths = c("file1.lp", "file2.lp"),
solvers = c("glpk", "gurobi")
)
expectedSolutions = list(`file1.lp` = 10, `file2.lp` = 20)
testFactory <- function(filePath, solver){
test_that(paste("Testing ", solver, "on", filePath), {
payload$config$solver = solver
payload$config$filePath = filePath
sol = AlteryxSolve(payload)
expect_equal(sol$objval, expectedSolutions[[filePath]])
})
}
mapply(testFactory, filePath = testGrid$filePath, solvers = testGrid$solver)
```
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Bewertung
Dieses Issue wurde noch nicht bewertet.