File tree Expand file tree Collapse file tree 5 files changed +47
-11
lines changed
Xunit.SkippableFact.Tests Expand file tree Collapse file tree 5 files changed +47
-11
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" utf-8" ?>
12<Project >
23 <PropertyGroup >
34 <BaseIntermediateOutputPath >$(MSBuildThisFileDirectory)..\obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath >
45 <OutputPath >$(MSBuildThisFileDirectory)..\bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath >
56 </PropertyGroup >
67 <ItemGroup >
7- <PackageReference Include =" Nerdbank.GitVersioning" Version =" 1.6.25 " PrivateAssets =" all" />
8+ <PackageReference Include =" Nerdbank.GitVersioning" Version =" 2.2.13 " PrivateAssets =" all" />
89 </ItemGroup >
910 <ItemGroup >
1011 <AdditionalFiles Include =" $(MSBuildThisFileDirectory)stylecop.json" />
Original file line number Diff line number Diff line change @@ -63,5 +63,15 @@ public void SkipTheoryMaybe(bool skip)
6363 {
6464 Skip . If ( skip , "I was told to." ) ;
6565 }
66+
67+ [ SkippableFact ]
68+ public void SkipInsideAssertThrows ( )
69+ {
70+ Assert . Throws < Exception > ( new Action ( ( ) =>
71+ {
72+ Skip . If ( true , "Skip inside Assert.Throws" ) ;
73+ throw new Exception ( ) ;
74+ } ) ) ;
75+ }
6676 }
6777}
Original file line number Diff line number Diff line change 1212 <ProjectReference Include =" ..\Xunit.SkippableFact\Xunit.SkippableFact.csproj" />
1313 </ItemGroup >
1414 <ItemGroup >
15- <PackageReference Include =" Validation" Version =" 2.4.15" />
16- <PackageReference Include =" xunit" Version =" 2.2.0" />
17- <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.2.0" />
18- <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 15.0.0" />
15+ <PackageReference Include =" Validation" Version =" 2.4.18" />
16+ <PackageReference Include =" xunit" Version =" 2.4.0" />
17+ <PackageReference Include =" xunit.runner.visualstudio" Version =" 2.4.0" >
18+ <IncludeAssets >runtime; build; native; contentfiles; analyzers</IncludeAssets >
19+ <PrivateAssets >all</PrivateAssets >
20+ </PackageReference >
21+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 15.8.0" />
1922 </ItemGroup >
20- </Project >
23+ </Project >
Original file line number Diff line number Diff line change @@ -58,14 +58,36 @@ public bool QueueMessage(IMessageSinkMessage message)
5858 if ( failed != null )
5959 {
6060 var outerException = failed . ExceptionTypes . FirstOrDefault ( ) ;
61- if ( outerException != null && Array . IndexOf ( this . SkippingExceptionNames , outerException ) >= 0 )
61+ bool skipTest = false ;
62+ string skipReason = null ;
63+ switch ( outerException )
64+ {
65+ case string _ when this . ShouldSkipException ( outerException ) :
66+ skipTest = true ;
67+ skipReason = failed . Messages . FirstOrDefault ( ) ;
68+ break ;
69+ case "Xunit.Sdk.ThrowsException" when failed . ExceptionTypes . Length > 1 :
70+ outerException = failed . ExceptionTypes [ 1 ] ;
71+ if ( this . ShouldSkipException ( outerException ) )
72+ {
73+ skipTest = true ;
74+ skipReason = ( failed . Messages ? . Length ?? 0 ) > 1 ? failed . Messages [ 1 ] : null ;
75+ }
76+
77+ break ;
78+ }
79+
80+ if ( skipTest )
6281 {
6382 this . SkippedCount ++ ;
64- return this . inner . QueueMessage ( new TestSkipped ( failed . Test , failed . Messages [ 0 ] ) ) ;
83+ return this . inner . QueueMessage ( new TestSkipped ( failed . Test , skipReason ) ) ;
6584 }
6685 }
6786
6887 return this . inner . QueueMessage ( message ) ;
6988 }
89+
90+ private bool ShouldSkipException ( string exceptionType ) =>
91+ Array . IndexOf ( this . SkippingExceptionNames , exceptionType ) >= 0 ;
7092 }
7193}
Original file line number Diff line number Diff line change 1616 <PackageTags >xunit testing skipping</PackageTags >
1717 </PropertyGroup >
1818 <ItemGroup >
19- <PackageReference Include =" Validation" Version =" 2.4.15 " PrivateAssets =" compile;contentfiles;analyzers;build" />
19+ <PackageReference Include =" Validation" Version =" 2.4.18 " PrivateAssets =" compile;contentfiles;analyzers;build" />
2020 <PackageReference Include =" xunit.extensibility.execution" Version =" 2.1.0" Condition =" '$(TargetFramework)' == 'net45' " />
21- <PackageReference Include =" xunit.extensibility.execution" Version =" 2.2 .0" Condition =" '$(TargetFramework)' != 'net45' " />
22- <PackageReference Include =" StyleCop.Analyzers" Version =" 1.0.0 " PrivateAssets =" all" />
21+ <PackageReference Include =" xunit.extensibility.execution" Version =" 2.4 .0" Condition =" '$(TargetFramework)' != 'net45' " />
22+ <PackageReference Include =" StyleCop.Analyzers" Version =" 1.0.2 " PrivateAssets =" all" />
2323 <PackageReference Update =" NETStandard.Library" PrivateAssets =" all" />
2424 </ItemGroup >
2525 <Target Name =" SetNuSpecProperties" BeforeTargets =" GenerateNuspec" DependsOnTargets =" GetBuildVersion" >
You can’t perform that action at this time.
0 commit comments