alteryx / alteryx/AlteryxPrescriptive
Write a testFactory function.
- Ngôn ngữ chính
- R
- Star
- 3
- Fork
- 5
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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)
```
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Đánh giá
Issue này chưa được đánh giá.