jediwhale / fitsharp

Functional testing tools for .NET
http://fitsharp.github.io
Other
152 stars 73 forks source link

Problem expecting exceptions #138

Closed Thaoden closed 8 years ago

Thaoden commented 9 years ago

Hi,

I try to catch an exception in my DoFixture:

|etc|etc|etc|exception[System.IndexOutOfRangeException: "Couldn't create new loginId - giving up"]|

When I run the test, it throws the expected exception with a stack trace, but the check fails:

exception[System.IndexOutOfRangeException: "Couldn't create new loginId - giving up"] expected
System.IndexOutOfRangeException: Couldn't create new loginId - giving up 
at (stack) actual

Replacing the exception with an error keyword makes the test pass - but I'd like to check on the type and message of the exception too. Any hint what I should change?

Thanks!

jediwhale commented 9 years ago

Can you post the exact content of the test and the full stack trace of the result?

Thaoden commented 9 years ago

This is the corresponding test:

!|GenerateUsername|
!define amount {66925}
|check | Generate | ${amount} | Guest User For Guest Host | abc | With Given name | Jadzia | And Surname | Dax | And Email | jadzia.dax@test.mydomain.de| exception[System.IndexOutOfRangeException: "Couldn't create new loginId - giving up"]|

I attached a screenshot of the stacktrace: dofixture

Inlining the amount-variable didn't help.

jediwhale commented 8 years ago

The exception keyword is looking for the exception type name not the fully-qualified name.

So you need to use this:

|exception[IndexOutOfRangeException: "Couldn't create new loginId - giving up"]|

On 2015-09-07 06:38, Thaoden wrote:

Hi,

I try to catch an exception in my DoFixture:

etc etc etc exception[System.IndexOutOfRangeException: "Couldn't create new loginId - giving up"]

When I run the test, it throws the expected exception with a stack trace, but the check fails:

exception[System.IndexOutOfRangeException] expected System.IndexOutOfRangeException: Couldn't create new loginId - giving up at (stack) actual

Replacing the exception with an |error| keyword makes the test pass - but I'd like to check on the type and message of the exception too. Any hint what I should change?

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/jediwhale/fitsharp/issues/138.

Cheers, Mike Stockdale

/fit/Sharp http://fitsharp.github.com Syterra Software Inc. http://www.syterra.com