在我的Azure管道中,我正在尝试构建和运行代码。因此,我包括了“ NuGet Restore”,“构建解决方案”和“ VS测试”任务。
当我尝试在VS Test中应用过滤条件时,显示的错误是在该搜索条件中找不到测试用例:
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.Objects\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll
Running all tests in C:\AzureAgent2\_work\2\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\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll
Running all tests in C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\NUnit3.TestAdapter.dll
NUnit couldn't find any tests in C:\AzureAgent2\_work\2\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\2\s\Main\Business\Automation.Objects\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.PageObjects\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.Resource\bin\Release\NUnit3.TestAdapter.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Automation.TestSuite.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.Test.WebApi.dll C:\AzureAgent2\_work\2\s\Main\Business\Automation.TestSuite\bin\Release\Microsoft.TeamFoundation.TestManagement.WebApi.dll C:\AzureAgent2\_work\2\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")]
答案 0 :(得分:0)
我对此进行了测试,并且效果很好。
测试项目
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'
看起来像这样