File tree Expand file tree Collapse file tree 5 files changed +48
-4
lines changed
Exceptions/OtherExceptions Expand file tree Collapse file tree 5 files changed +48
-4
lines changed Original file line number Diff line number Diff line change 2
2
<package xmlns : xsd =" http://www.w3.org/2001/XMLSchema" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" >
3
3
<metadata xmlns =" http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" >
4
4
<id >TestStack.BDDfy</id >
5
- <version >3.14 </version >
5
+ <version >3.15 </version >
6
6
<title >A simple to use and extend BDD framework for .Net programmers</title >
7
7
<authors >Mehdi Khalili, Michael Whelan</authors >
8
8
<owners >Mehdi Khalili, Michael Whelan</owners >
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Xml ;
3
+ using NUnit . Framework ;
4
+
5
+ namespace TestStack . BDDfy . Tests . Exceptions . OtherExceptions
6
+ {
7
+ public class WhenResolvingExceptionsFromDifferentScanners
8
+ {
9
+ private ExceptionThrowingTest < OuterException > _sut ;
10
+
11
+ /// <summary>
12
+ /// Test to resolve issue where fluent scanner was returning the inner exception rather than the outer one.
13
+ /// Issue 17: https://github.com/TestStack/TestStack.BDDfy/issues/17
14
+ /// </summary>
15
+ [ Test ]
16
+ public void FluentScannerShouldReturnOriginalExceptionAndNotInnerException ( )
17
+ {
18
+ _sut = new ExceptionThrowingTest < OuterException > ( ) ;
19
+ Assert . Throws < OuterException > ( ( ) => _sut . Execute ( ThrowingMethods . Given , true ) ) ;
20
+ }
21
+
22
+ [ Test ]
23
+ public void ReflectiveScannerShouldReturnOriginalExceptionAndNotTargetInvocationException ( )
24
+ {
25
+ _sut = new ExceptionThrowingTest < OuterException > ( ) ;
26
+ Assert . Throws < OuterException > ( ( ) => _sut . Execute ( ThrowingMethods . Given , false ) ) ;
27
+ }
28
+
29
+ private class OuterException : Exception
30
+ {
31
+ public OuterException ( )
32
+ : base ( "outer" , new XmlException ( "inner exception" ) )
33
+ {
34
+ }
35
+ }
36
+ }
37
+
38
+ }
Original file line number Diff line number Diff line change 58
58
<Compile Include =" Configuration\BatchProcessorsTests.cs" />
59
59
<Compile Include =" Configuration\ProcessorPipelineTests.cs" />
60
60
<Compile Include =" Disposer\DisposingScenarios.cs" />
61
+ <Compile Include =" Exceptions\OtherExceptions\WhenResolvingExceptionsFromDifferentScanners.cs" />
61
62
<Compile Include =" Exceptions\ThrowingMethods.cs" />
62
63
<Compile Include =" Exceptions\WhenAnInconclusiveTestIsRun.cs" />
63
64
<Compile Include =" Exceptions\ExceptionThrowingTest.cs" />
Original file line number Diff line number Diff line change 1
1
using System ;
2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
+ using System . Reflection ;
4
5
5
6
namespace TestStack . BDDfy . Core
6
7
{
@@ -48,7 +49,11 @@ public StepExecutionResult ExecuteStep(ExecutionStep executionStep)
48
49
catch ( Exception ex )
49
50
{
50
51
// ToDo: more thought should be put into this. Is it safe to get the exception?
51
- var exception = ex . InnerException ?? ex ;
52
+ var exception = ex ;
53
+ if ( exception is TargetInvocationException )
54
+ {
55
+ exception = ex . InnerException ?? ex ;
56
+ }
52
57
53
58
if ( exception is NotImplementedException )
54
59
{
Original file line number Diff line number Diff line change 11
11
[ assembly: AssemblyCulture ( "" ) ]
12
12
[ assembly: ComVisible ( false ) ]
13
13
14
- [ assembly: AssemblyVersion ( "3.14 " ) ]
15
- [ assembly: AssemblyFileVersion ( "3.14 " ) ]
14
+ [ assembly: AssemblyVersion ( "3.15 " ) ]
15
+ [ assembly: AssemblyFileVersion ( "3.15 " ) ]
You can’t perform that action at this time.
0 commit comments