Therefore exception of required type thrown from any place in the test will make running of the test succeeded although it should be failed.
On 11/14/06, Jonathan de Halleux <[EMAIL PROTECTED]> wrote:
The corret way to get expected exception per row is to use the ExectedException attribute constructor argument, otherwize the expectedexception should (not sure anymore) be applied to each generated test.ps: Rembember that there is no guarantee on the order of attributes.Cheers,Peli
This posting is provided "AS IS" with no warranties, and confers no rights.On 11/13/06, Johan Appelgren <[EMAIL PROTECTED] > wrote:
On Nov 10, 9:06 pm, "pprewett" < [EMAIL PROTECTED] > wrote:
> I have a question regarding using RowTests and the ExpectedException
> attribute.
>
> It appears as though you can only have one Row on your RowTest if you
> are using the ExpectedException attribute.
>
> For example, this test passes:
>
> [RowTest]
> [Row(1), ExpectedException(typeof(FormatException))]
> public void test1(int p_Dummy)
> {
> throw new FormatException();
> }
>
> But this test fails on both rows:
>
> [RowTest]
> [Row(1), ExpectedException(typeof(FormatException))]
> [Row(2), ExpectedException(typeof(FormatException))]
> public void test2(int p_Dummy)
> {
> throw new FormatException();
> }
>
> Is this how it's supposed to behave?
>
> Thanks,
> Paul Prewett
To expect an exception on all rows in a RowTest I think you can only
specify the ExpectedException attribute once. If this is correct the
error handling could probably be improved. So the test below expects
all rows to throw.
[RowTest]
[ExpectedException(typeof(FormatException))]
[Row(1)]
[Row(2)]
public void test2(int p_Dummy)
{
throw new FormatException();
}
But what you wrote in your second example is equivalent of the
following I believe.
[RowTest]
[Row(1)]
[ExpectedException(typeof(FormatException))]
[Row(2)]
[ExpectedException(typeof(FormatException))]
public void test2(int p_Dummy)
{
throw new FormatException();
}
If you want to specify whether an exception is thrown or not per row
you use the ExpectedException property of the Row attribute.
[RowTest]
[Row(1, ExpectedException=typeof(FormatException))]
[Row(2)]
public void test2(int p_Dummy)
{
if(p_Dummy == 1)
throw new FormatException();
}
Hopefully this is correct :)
--
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "MbUnit.User" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/MbUnitUser?hl=en
-~----------~----~----~----~------~----~------~--~---
