alteryx / alteryx/AlteryxPrescriptive
Write a testFactory function.
- 主要言語
- R
- スター
- 3
- フォーク
- 5
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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)
```
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。