0

我正在为多线程 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
}
4

1 回答 1

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 ""
于 2016-11-30T22:40:55.003 回答