在NUnit测试中发布结果

时间:2013-08-26 09:34:32

标签: powershell nunit

我正在为多线程NUnit测试编写PowerShell脚本。我的问题是我从文件category.txt中获取测试类别,我必须在输出文件file 1.txt中写入已经完成的类别。我还需要在执行所有测试后输出XML报告。我怎么能在NUnit中做到这一点?

$Groups=Get-Content d:\test\category.txt | Select-Object -Last 10
Write-Host $Groups
if ($Groups -ne $null)
    {Write-Host "true"} 
else 
    {write-host "false"}
###Multithreading###
$ThreadNumber =$Groups.Count
$ScriptBlock = {
    function Nunit {
        $Connection = @{"server" = ""; "username" = ""; "password" = ""}
        write-verbose $Connection
        $serv = $connection.Get_Item("server")
        $user = $connection.Get_Item("username")
        $pass = $connection.Get_Item("password")

        $securePassword = ConvertTo-SecureString -AsPlainText $pass -Force
        #Create connection credentials object for Invoke-Command
        $cred   = new-object -typename System.Management.Automation.PSCredential -argumentlist $user, $securePassword
        $Output = "C:\"
        $scriptBlock = {
            CMD.EXE /C "C:\testNunit\bin\nunit-console.exe /xml:c:\console-test.xml C:\testNunit\dll\Tests.dll /include:TestTypeSmoke> c:\1.txt" 
        }
        Invoke-Command -ComputerName $serv -ScriptBlock  $scriptBlock -credential $cred
    }
    Nunit
}

1 个答案:

答案 0 :(得分:0)

在我尝试了一些事情之后,我会尝试在NUnit上回复你,但作为建议,你也可以尝试PowerShell Workflow for Multi-Threading。它们像功能一样工作。

    Workflow NUnit
    {
        Param
        (
            $server,
            $username,
            $password,              
        )

                foreach -parallel -throttlelimit 2($group in $groups)
                try{
                    //NUnit Code here
                }
            }
            Catch
            {
               $_.Exception.Message
            }   
        }
    }
    NUnit-server "" -username "" -password ""
相关问题