5
하나의 TestMethod에서 여러 예외를 원합니다. Testmethod가 처음 던져진 예외 다음에 멈추는 문제가 있습니다.UnitTest 여러 예외가있는 ExpectedException
는 내가 그런 일 할 수 있다는 사실을 알고 :
try
{
sAbc.ToInteger();
Assert.Fail(); // If it gets to this line, no exception was thrown
}
catch (ArgumentException) { }
을하지만, 나는 다음과 같은 코드베이스를 사용하려면 :
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sAbc.ToInteger(); // throws an exception and stops here
sDecimal.ToInteger(); // throws theoretically a exception too...
}
을 그리고 나는 하나 testmethod을 만들지 않으 각각의 가능한 예외는 다음과 같습니다.
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sAbc.ToInteger();
}
[TestMethod, ExpectedException(typeof(ArgumentException), "...")]
public void StringToIntException()
{
sDecimal.ToInteger();
}
방법에 대한 또는 형 여러 예외를 : 당신이 정말로이 기능이 필요하면
는이 NUnit을 사용합니까? 한 번에 하나의 예외 만 발생합니다. mstest가이를 달성 할 수 있습니까? – liang