alteryx / alteryx/AlteryxPrescriptive

Write a testFactory function.

Open
#1 2 comments 0 reactions 0 assignees View on GitHub
testing
Dominant language
R
Stars
3
Forks
5
PR merge metrics
No merged PRs in 30d

Description

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)
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.