As mentioned in the other thread, adding new parameters to
ExpectedException or TestCaseData is something we want to get away
from. Some people would like to have an expected message, some people
would like to access the parameter name of an ArgumentNull exception,
some people would like the hresult. It's an endless task.
In the case of ExpectedException, we went a long way toward trying to
make folks happy, but eventually realized that we were just making the
API more and more complex, with insufficient benefit.
In fact, testing the result of an exception with Assert.Throws is much
superior to using ExpectedException attribute or the equivalent
TestCaseData syntax. When you make the test inline, you know exactly
where in the code your exception was thrown whereas use of
ExpectedException only tells you it was thrown somewhere in the method
- and maybe not from the place where you imagine it was thrown.
However, with all that said, I'd like to give some consideration to
what you want. So... what do you want? That is, what syntax would you
like to use, if it existed.
Charlie
On Fri, Jan 11, 2013 at 12:58 PM, Stecy Dube <
stecy...@gmail.com> wrote:
> Hello to all,
>
> Not sure if it is something I missed but here's what I have:
>
> [TestFixture]
> public class MyFixtureTests
> {
> private class MySource : IEnumerable
> {
> private readonly TestCaseData[] _testCases = new[]
> {
> new TestCaseData (20, 2).Returns (10),
> new TestCaseData (1, 0).Throws (typeof
> (DivideByZeroException))
> };
>
> public IEnumerator GetEnumerator ()
> {
> return _testCases.GetEnumerator ();
> }
> }
>
> [TestCaseSource (typeof (MySource))]
> public int TestDivision (int a, int b)
> {
> return a/b;
> }
> }
>
>
> However, I cannot specify additional conditions for the exception test like
> I could with Assert.Throws()
>
> var ex = Assert.Throws<ArgumentNullException> (() => ......);
> Assert.That (ex.ParamName, Is.EqualTo ("param1"));
>
>
> Could it be considered to add this feature to NUnit 2.6 ?
>
> Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/nunit-discuss/-/UQ-nGbEmUo8J.
> To post to this group, send email to
nunit-...@googlegroups.com.
> To unsubscribe from this group, send email to
>
nunit-discus...@googlegroups.com.
> For more options, visit this group at
>
http://groups.google.com/group/nunit-discuss?hl=en.