TestAttribute와 동시에 CategoryAttribute로 동작 할 사용자 지정 NUnit 특성을 만들 수 있는지 궁금합니다. 당신은 하나의 클래스에 대한이 개 기본 클래스를 가질 수 없습니다로TestAttribute와 CategoryAttribute로 동시에 동작하는 NUnit 사용자 지정 속성
public class UnitTestAttribute : TestAttribute, CategoryAttribute, ITestAction
{
public UnitTestAttribute() : base("UnitTest")
public void BeforeTest(ITest test) { /*some logic*/ }
public void AfterTest(ITest test) { /*some logic*/ }
public ActionTargets Targets => ActionTargets.Test;
}
불행하게도,이 작동하지 않습니다
NUnit documentation - Test Attribute NUnit documentation - Category Attribute
은 무엇을 달성하려고하면이 같은 것입니다. 달성하기 위해 노력하고있어 꽤 많은 테스트를 (이 경우) 단위 테스트로 표시하려면 코드 작성량을 최소화해야하지만 동시에 해당 범주에 따라 테스트를 필터링 할 수 있어야합니다 . 그래서 내 현재 코드는
[Test, UnitTest]
public void SomeTest() { /*doing some stuff*/ }
는
[UnitTest]
public void SomeTest() { /*doing some stuff*/ }
로 변경됩니다 그리고 난 아직도 다음 명령을
nunit3-console mytest.dll --where "cat == UnitTest"
를 사용하여 테스트를 실행할 수 및 테스트 탐색기는 찾을 또한 VS 카테고리 등