alteryx / alteryx/AlteryxPrescriptive

Write a testFactory function.

未关闭
#1 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
testing
主要语言
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 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。