【问题标题】:FAKE specify NUnit Namespace/Fixture when running testsFAKE 在运行测试时指定 NUnit 命名空间/夹具
【发布时间】:2014-12-28 02:50:19
【问题描述】:

在我的 Powershell 脚本 (PSAKE) 中,我能够指定在执行 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

我正在切换到 FAKE,因为它维护起来更干净,但是我不知道如何为我的测试指定 Fixture。

IE:现在我有

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

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

【问题讨论】:

    标签: f# nunit f#-fake f#-fake-4


    【解决方案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"
        })
    )
    

    【讨论】:

    • 甜蜜!这真的很新(我两周前才开始使用 Fake)。像冠军一样工作。
    猜你喜欢
    • 1970-01-01
    • 2018-03-07
    • 1970-01-01
    • 2011-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-23
    • 1970-01-01
    相关资源
    最近更新 更多