2013-08-26 81 views
0

我正在为多线程NUnit测试编写一个PowerShell脚本。我的问题是,我从category.txt文件中获取测试类别,并且必须在输出文件file 1.txt中编写完成哪些类别。我还需要在所有测试完成后输出XML报告。我怎样才能在NUnit中做到这一点?在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 
} 

回答

0

我会尽我的努力到底有些东西后要回你NUnit的,但作为一个建议,你也可以尝试PowerShell的工作流的多线程。他们像功能一样工作。

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

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