![](/img/trans.png)
[英]Error finding configuration file when using nunit3-console runner
[英]Using category expressions in Nunit console runner
在使用/ include或/ exclude語句時,我正在閱讀關於類別表達式的鏈接 。 我希望能夠僅包括運行測試以用於兩個可用的測試或運行所有測試但使用/ include:A + B或/ exclude:A。 但是,由於某種原因,它顯示了要運行和/或未運行的錯誤測試數。 這是為什么?
任何人都可以提供一個關於如何分類表達式(通過操作源代碼)並添加如何在控制台中運行命令的示例?
基本上我做的是:
using System;
using NUnit;
using NUnit_Application;
using NUnit.Framework;
namespace NUnit_Application.Test
{
[TestFixture]
[Category("MathS")]
public class TestClass
{
[TestCase]
[Category("MathA")]
public void AddTest()
{
MathsHelper helper = new MathsHelper();
int result = helper.Add(20, 10);
Assert.AreEqual(40, result);
}
[TestCase]
[Category("MathB")]
public void SubtractTest()
{
MathsHelper helper = new MathsHelper();
int result = helper.Subtract(20, 10);
Assert.AreEqual(10, result);
}
}
}
我的命令行語句是nunit-console /framework:net-4.0 /run:NUnit_Application.Test.TestClass.AddTest C:〜\\ NUnit_Application \\ NUnit_Application \\ NUnit_Application.Test \\ bin \\ Debug \\ NUnit_Application.Test.dll / include:“瑪莎”
問題是,控制台熟悉命令的含義,並說它包含數學A類。 但是,它表明已經運行了零測試,並且沒有運行零測試。
我正在運行NUnit 2.6.2,即控制台運行程序。
這是我最初使用的命令:
nunit-console /framework:net-4.0 /run:NUnit_Application.Test.TestClass.AddTest C:~\NUnit_Application\NUnit_Application\NUnit_Application.Test\bin\Debug\NUnit_Application.Test.dll /include:"MathA"
我注意到如果我只是調用TestClass而不是單獨的測試用例,它可以工作:
nunit-console /framework:net-4.0 /run:NUnit_Application.Test.TestClass C:~\NUnit_Application\NUnit_Application\NUnit_Application.Test\bin\Debug\NUnit_Application.Test.dll /include:"MathA"
我認為這是因為你擁有屬性的全班:
[Category("MathS")]
所以它會跳過它。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.