The NUnit GUI does not support loading multiple assemblies from the command line, so this PowerShell function creates an NUnit project file that can be specified as a command line argument. Just provide a file name for the new project file (must end in .nunit or NUnit will barf) and an array of assembly files to load.
As a bonus, this project file will load your assemblies in multiple process mode, which means that any associated assembly configuration files will be correctly loaded.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function WriteNUnitProjectFile( | |
[string][parameter(mandatory)]$projectFilePath, | |
[string[]][parameter(mandatory)]$assemblyPaths) | |
{ | |
$xmlWriter = New-Object System.Xml.XmlTextWriter $projectFilePath, $null | |
try { | |
$xmlWriter.Formatting = "Indented" | |
$xmlWriter.Indentation = "4" | |
$xmlWriter.WriteStartDocument() | |
$xmlWriter.WriteStartElement("NUnitProject") | |
$xmlWriter.WriteStartElement("Settings") | |
$xmlWriter.WriteAttributeString("activeconfig", 'Default') | |
$xmlWriter.WriteAttributeString("processModel", 'Multiple') | |
$xmlWriter.WriteEndElement() | |
$xmlWriter.WriteStartElement("Config") | |
$xmlWriter.WriteAttributeString("name", 'Default') | |
$xmlWriter.WriteAttributeString("binpathtype", 'Auto') | |
$assemblyPaths | % { | |
$xmlWriter.WriteStartElement("assembly") | |
$xmlWriter.WriteAttributeString("path", $_) | |
$xmlWriter.WriteEndElement() | |
} | |
$xmlWriter.WriteEndElement() | |
$xmlWriter.WriteEndElement() | |
$xmlWriter.WriteEndDocument() | |
} | |
finally { | |
$xmlWriter.Dispose(); | |
} | |
} |
0 comments:
Post a Comment