alteryx / alteryx/AlteryxPrescriptive
Write a testFactory function.
- Lenguaje dominante
- R
- Estrellas
- 3
- Forks
- 5
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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)
```
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.