Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the plugin to allow a configurable start #49

Merged
merged 1 commit into from
Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,18 @@ It creates a task 'nunit' that may be configured as follows:
include = 'BaseLine'
// for NUnit v3+, use _where_ option instead of include/exclude
framework = 'net-1.1'
shadowCopy = true
shadowCopy = true
// redirect output to file
logFile = 'TestOutput.log'

// for NUnit v3+
resultFormat = 'nunit2'

// environment variables map (already defined)
env = [:]

// optional - if set, can overwrite the default command arguments in order to allow running of external tools like dotMemoryUnit
nunitCommandModifier = { nunitBin, args -> [nunitBin, *args] }
}

# License
Expand Down
9 changes: 8 additions & 1 deletion src/main/groovy/com/ullink/gradle/nunit/NUnit.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class NUnit extends ConventionTask {
def test = Wrapper.newInstance()
def where = Wrapper.newInstance()
def testList
def nunitCommandModifier = { nunitBin, args ->
[nunitBin, *args]
}

Map<String, Object> env = [:]

Expand Down Expand Up @@ -259,8 +262,12 @@ class NUnit extends ConventionTask {
return combine(testInput)
}

def getCommandLine(input, reportPath){
return nunitCommandModifier(getNunitExec().absolutePath, buildCommandArgs(input, reportPath))
}

def run(def input, def reportPath) {
def cmdLine = [getNunitExec().absolutePath, *buildCommandArgs(input, reportPath)]
def cmdLine = getCommandLine(input, reportPath)
if (!isFamily(FAMILY_WINDOWS)) {
cmdLine = ["mono", *cmdLine]
}
Expand Down
28 changes: 28 additions & 0 deletions src/test/groovy/com/ullink/NUnitTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,34 @@ public class NUnitTest {
assert commandArgs.find { it =~ /-result:.*TestResult\.xml;format=nunit3/ }
}

@Test
public void whenRun_withDefaultCommandModifier_setsPathAndBuildArgs()
{
def nunit = getNUnitTask()

def cmdLine = nunit.getCommandLine('input', 'path')

assert cmdLine == [nunit.getNunitExec().absolutePath, *nunit.buildCommandArgs('input', 'path')]
}

@Test
public void whenRun_withCustomCommandModifier_setsPathAndBuildArgsWithCustomArguments() {
def nunit = getNUnitTask()

nunit.nunitCommandModifier = { path, args ->
['dotMemoryUnit.exe', path, 'custom-args', *args]
}

def cmdLine = nunit.getCommandLine('input', 'path')

assert cmdLine == [
'dotMemoryUnit.exe',
nunit.getNunitExec().absolutePath,
'custom-args',
*nunit.buildCommandArgs('input', 'path')
]
}

def getNUnitTask() {
def project = ProjectBuilder.builder().build()
project.apply plugin: 'nunit'
Expand Down