2013-08-26 114 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 "" 
相關問題