TeamCity构建配置,允许NUnit和xUnit测试

时间:2017-10-31 12:19:08

标签: nunit teamcity xunit

我们有一个包含大约20个项目的解决方案文件,其中大约一半是测试项目。直到最近,我们才使用NUnit,但现在我们也开始引入xUnit(原因与问题无关)。总共大约有1800个测试,所以一次性移植它们不是一个选择 - 我们必须将NUnit和xUnit混合使用我们的TeamCity CI / CD管道。

在向TeamCity项目添加xUnit构建配置步骤之前,我签入并推送了一个在新项目中添加了几个xUnit测试的提交。这使得NUnit步骤失败,问题底部的日志输出,并且 - 重要的是 - 中止测试运行,即使是剩余的NUnit程序集

如何将TeamCity配置为从同一组程序集中运行NUnit和xUnit测试,忽略未找到测试的程序集?

按照承诺记录输出:

Starting: C:\TeamCity- Agent\work\cecd2801408764e0\packages\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe C:\TeamCity-Agent\temp\buildTmp\bBDbo6pa0lGnLMZYjY7WcvIGUDDIvWI7.nunit --result=C:\TeamCity-Agent\temp\buildTmp\bBDbo6pa0lGnLMZYjY7WcvIGUDDIvWI7.nunit.xml --noheader --framework=net-4.0
[11:08:59]  [Step 4/4] in directory: C:\TeamCity-Agent\work\cecd2801408764e0\My.xUnit.Tests\bin\Release
[11:08:59]  [Step 4/4] Runtime Environment
[11:08:59]  [Step 4/4] OS Version: Microsoft Windows NT 6.3.9600.0
[11:08:59]  [Step 4/4] CLR Version: 4.0.30319.42000
[11:08:59]  [Step 4/4]
[11:08:59]  [Step 4/4] Test Files
[11:08:59]  [Step 4/4] C:\TeamCity-Agent\temp\buildTmp\bBDbo6pa0lGnLMZYjY7WcvIGUDDIvWI7.nunit
[11:08:59]  [Step 4/4]
[11:09:00]  [Step 4/4]
[11:09:00]  [Step 4/4] Errors, Failures and Warnings
[11:09:00]  [Step 4/4]
[11:09:00]  [Step 4/4] 1) Invalid : C:\TeamCity-Agent\work\cecd2801408764e0\My.xUnit.Tests\bin\Release\My.xUnit.Tests.dll
[11:09:00]  [Step 4/4] No suitable tests found in 'C:\TeamCity-Agent\work\cecd2801408764e0\My.xUnit.Tests\bin\Release\My.xUnit.Tests.dll'.
[11:09:00]  [Step 4/4] Either assembly contains no tests or proper test driver has not been found.
[11:09:00]  [Step 4/4]
[11:09:00]  [Step 4/4] Test Run Summary
[11:09:00]  [Step 4/4] Overall result: Failed
[11:09:00]  [Step 4/4] Test Count: 0, Passed: 0, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
[11:09:00]  [Step 4/4] Start time: 2017-10-31 10:08:59Z
[11:09:00]  [Step 4/4] End time: 2017-10-31 10:09:00Z
[11:09:00]  [Step 4/4] Duration: 0.494 seconds
[11:09:00]  [Step 4/4]
[11:09:00]  [Step 4/4] Results (nunit3) saved as C:\TeamCity-Agent\temp\buildTmp\bBDbo6pa0lGnLMZYjY7WcvIGUDDIvWI7.nunit.xml
[11:09:00]  [Step 4/4] Process exited with code -2

1 个答案:

答案 0 :(得分:1)

您可以通过将Option Explicit Sub test() Dim LC3, z As Long Dim ws As Worksheet Dim startColumn As Integer Dim checkRow As Integer Dim headerColumn As Integer Dim allTheSame As Boolean Dim allEmpty As Boolean Set ws = Worksheets("wc") LC3 = ws.Cells(ws.UsedRange.Rows.Count, 2).End(xlToRight).Column startColumn = 3 checkRow = 15 headerColumn = 2 ' 'if first column is blank delete the header ' If ws.Cells(checkRow, startColumn).Value = "" Then ' ws.Cells(checkRow, headerColumn).Value = "" ' Exit Sub ' End If ' allTheSame = True allEmpty = True For z = startColumn To LC3 'if any column is blank delete the header ' If ws.Cells(checkRow, z).Value = "" Then ' ws.Cells(checkRow, headerColumn).Value = "" ' 'Exit For ' End If 'if one is not the same delete header ' If z + 1 <= LC3 Then ' If ws.Cells(checkRow, z).Value <> ws.Cells(checkRow, z + 1).Value Then ' ws.Cells(checkRow, headerColumn).Value = "" ' Exit For ' End If ' End If 'if any column is blank delete the header If ws.Cells(checkRow, z).Value <> "" Then allEmpty = False 'Exit For End If 'if all are the same, delete header If z + 1 <= LC3 Then If ws.Cells(checkRow, z).Value <> ws.Cells(checkRow, z + 1).Value Then allTheSame = False End If End If Next z If allTheSame Or allEmpty Then ws.Cells(checkRow, headerColumn).Value = "" End If End Sub 添加到“其他命令行参数”部分来配置NUnit以跳过没有测试的程序集。