2014-10-31 46 views
1

在我的Powershell脚本(PSAKE)中,我可以指定在执行NUnit测试运行器时运行的名称空间/灯具。运行测试时,FAKE指定NUnit命名空间/灯具

task UnitTest -Depends Compile -Description "Runs only Unit Tests" { 
    Invoke-Nunit "$buildOutputDir\$testAssembly.dll" "$testAssembly.Unit" $buildArtifactsDir 
} 

task IntegrationTest -Depends Compile -Description "Runs only Integration Tests" { 
    Invoke-Nunit "$buildOutputDir\$testAssembly.dll" "$testAssembly.Integration" $buildArtifactsDir 
} 

task FunctionalTest -Depends Compile -Description "Runs only Functional Tests" { 
    Invoke-Nunit "$buildOutputDir\$testAssembly.dll" "$testAssembly.Functional" $buildArtifactsDir 
} 

这让我有三个输出

Unit-TestResults.xml 
Integration-TestResults.xml 
Functional-TestResults.xml 

我在切换伪造的过程,因为它只是这么多的清洁维护,但我想不出如何为我的测试指定Fixture。

IE:现在我有

// Run Tests 
Target "Tests" (fun _ -> 
    testDlls 
    |> NUnit (fun p -> 
     {p with 
      DisableShadowCopy = true; 
      OutputFile = artifactDir + "/TestResults.xml" 
    }) 
) 

但这运行所有测试,并且将其放入到一个单一的输出。我真的很想指定Fixture,并且能够将它全部分开。有没有办法做到这一点?

回答

1

最新版本的FAKE增加了对Fixture参数的支持。你应该可以这样做:

Target "Tests" (fun _ -> 
    testDlls 
    |> NUnit (fun p -> 
     {p with 
      Fixture ="Namespace.Unit" 
      DisableShadowCopy = true; 
      OutputFile = artifactDir + "/Unit-TestResults.xml" 
    }) 
    testDlls 
    |> NUnit (fun p -> 
     {p with 
      Fixture ="Namespace.Integration" 
      DisableShadowCopy = true; 
      OutputFile = artifactDir + "/Integration-TestResults.xml" 
    }) 
    testDlls 
    |> NUnit (fun p -> 
     {p with 
      Fixture ="Namespace.Functional" 
      DisableShadowCopy = true; 
      OutputFile = artifactDir + "/Functional-TestResults.xml" 
    }) 
) 
+0

甜!这真的很新(我刚刚在2周前开始使用Fake)。像冠军一样工作。 – 2014-11-12 21:14:42

+2

@ChaseFlorell,当我读到你的问题时就让PR'ed了 – 2014-11-12 21:54:05