Azure Pipelines - VS 测试任务在提供筛选条件时失败
Azure Pipelines - VS Test task fails upon providing filter criteria
在我的 Azure Pipeline 中,我正在尝试构建和 运行 代码。所以我已经包含了 "NuGet Restore"、"Build Solution" 和 "VS Test" 任务。
当我尝试在 VS 测试中应用筛选条件时,它显示错误,即在该搜索条件中找不到测试用例:
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.Objects\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Automation.TestSuite.dll
NUnit3TestExecutor converted 213 of 213 NUnit test cases
Skipping assembly - no matching test cases found
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
NUnit Adapter 3.9.0.0: Test execution complete
No test matches the given testcase filter `Category = Enrollment` in C:\AzureAgent2\_work\s\Main\Business\Automation.Objects\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Automation.TestSuite.dll C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
我的测试套件看起来像。
// [Category("Enrollment")]
// [Category("Regression_TS")]
// [Test, TestTimeOutValue, Parallelizable(ParallelScope.Self), TestDescription("Enroll_001 - Enroll Button\n" +
// "Enroll_002 - Log In to Business\n" +
// "Enroll_003 - Log Out of Business")]
我测试了这个,它工作正常。
测试项目
using NUnit.Framework;
namespace UnitTestProject1
{
public class UnitTest1
{
[Category("Enrollment")]
[Test]
public void TestMethod1()
{
Assert.True(true);
}
[Test]
public void TestMethod2()
{
Assert.True(true);
}
}
}
安装的包
<packages>
<package id="NUnit" version="3.12.0" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="3.16.1" targetFramework="net48" developmentDependency="true" />
</packages>
在 VSTest 任务中,您在过滤器中添加以下代码
TestCategory=Enrollment
如果你使用YAML构建,应该是这一行
testFiltercriteria: 'TestCategory=Enrollment'
看起来像这样
最终结果
在我的 Azure Pipeline 中,我正在尝试构建和 运行 代码。所以我已经包含了 "NuGet Restore"、"Build Solution" 和 "VS Test" 任务。
当我尝试在 VS 测试中应用筛选条件时,它显示错误,即在该搜索条件中找不到测试用例:
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.Objects\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Automation.TestSuite.dll
NUnit3TestExecutor converted 213 of 213 NUnit test cases
Skipping assembly - no matching test cases found
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll
Running all tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
NUnit Adapter 3.9.0.0: Test execution complete
No test matches the given testcase filter `Category = Enrollment` in C:\AzureAgent2\_work\s\Main\Business\Automation.Objects\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Automation.TestSuite.dll C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll C:\AzureAgent2\_work\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
我的测试套件看起来像。
// [Category("Enrollment")]
// [Category("Regression_TS")]
// [Test, TestTimeOutValue, Parallelizable(ParallelScope.Self), TestDescription("Enroll_001 - Enroll Button\n" +
// "Enroll_002 - Log In to Business\n" +
// "Enroll_003 - Log Out of Business")]
我测试了这个,它工作正常。
测试项目
using NUnit.Framework;
namespace UnitTestProject1
{
public class UnitTest1
{
[Category("Enrollment")]
[Test]
public void TestMethod1()
{
Assert.True(true);
}
[Test]
public void TestMethod2()
{
Assert.True(true);
}
}
}
安装的包
<packages>
<package id="NUnit" version="3.12.0" targetFramework="net48" />
<package id="NUnit3TestAdapter" version="3.16.1" targetFramework="net48" developmentDependency="true" />
</packages>
在 VSTest 任务中,您在过滤器中添加以下代码
TestCategory=Enrollment
如果你使用YAML构建,应该是这一行
testFiltercriteria: 'TestCategory=Enrollment'
看起来像这样
最终结果