Runtime: `ConditionalFactAttribute` on the tests are ignored when ran on VS Test Explorer

Created on 26 Dec 2019  ยท  11Comments  ยท  Source: dotnet/runtime

It appears that ConditionalTheory Attributes on the tests are ignored during discovery / run and the tests are allowed to run regardless of the value returned from the predicate.

For example, Various tests under System.Net.Security.Tests were failing with TypeInitializationException, PlatformNotSupportedException and ObjectDisposedExceptions; it appears that most of them have ConditionalFact attributes, which when evaluated returns false.

Tests that had failed, though not all of them have the attribute:

Test    Duration    Traits  Error Message
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_AllowTwoOnBothSidesWithSingleOverlapNonTls13_Success Failed  < 1 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests Failed (31)   33 sec      
System.Net.Security.Tests Failed (31)   33 sec      
ClientAsyncAuthenticateTest Failed (3)  448 ms      
System.Net.Security.Tests.ClientAsyncAuthenticateTest.ClientAsyncAuthenticate_AllServerVsIndividualClientSupportedProtocols_Success(clientProtocol: Ssl3) Failed    6 ms        System.ComponentModel.Win32Exception : ํด๋ผ์ด์–ธํŠธ ๋ฐ ์„œ๋ฒ„์— ๊ณต์šฉ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— ํ†ต์‹ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
System.Net.Security.Tests.ClientAsyncAuthenticateTest.ClientAsyncAuthenticate_EachSupportedProtocol_Success(protocol: Ssl3) Failed  10 ms       System.ComponentModel.Win32Exception : ํด๋ผ์ด์–ธํŠธ ๋ฐ ์„œ๋ฒ„์— ๊ณต์šฉ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— ํ†ต์‹ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
System.Net.Security.Tests.ClientAsyncAuthenticateTest.ClientAsyncAuthenticate_IndividualServerVsAllClientSupportedProtocols_Success(serverProtocol: Ssl3) Failed    432 ms      System.IO.IOException : Authentication failed because the remote party has closed the transport stream.
NegotiateStreamKerberosTest Failed (3)  14 ms       
System.Net.Security.Tests.NegotiateStreamKerberosTest.NegotiateStream_ClientAuthenticationRemote_Fails Failed   1 ms    category [outerloop]    System.InvalidOperationException : The test method expected 1 parameter value, but 0 parameter values were provided.
System.Net.Security.Tests.NegotiateStreamKerberosTest.NegotiateStream_ClientAuthenticationRemote_Success Failed < 1 ms  category [outerloop]    System.InvalidOperationException : The test method expected 1 parameter value, but 0 parameter values were provided.
System.Net.Security.Tests.NegotiateStreamKerberosTest.NegotiateStream_ServerAuthenticationRemote_Success Failed 13 ms   category [outerloop]    System.NullReferenceException : Object reference not set to an instance of an object.
NegotiatedCipherSuiteTest Failed (18)   1 sec       
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_AllowOneOnOneSideTls13_Success Failed    2 ms        System.PlatformNotSupportedException : CipherSuitesPolicy is not supported on this platform.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_AllowSameTwoOnBothSidesLessPreferredIsTls13_Success Failed   < 1 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_AllowSomeCipherSuitesWithNoEncryptionOption_Fails Failed < 1 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_AllowTwoOnBothSidesWithNoOverlapNonTls13_Fails Failed    < 1 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_AllowedCipherSuitesIncludesSubsetOfInput_Success Failed  2 ms        System.PlatformNotSupportedException : CipherSuitesPolicy is not supported on this platform.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_NothingAllowed_Fails Failed  < 1 ms      System.PlatformNotSupportedException : CipherSuitesPolicy is not supported on this platform.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_OnlyNonTls13CipherSuiteAllowedButOtherSideDoesNotAllowIt_Fails Failed    < 1 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_OnlyNonTls13CipherSuitesAllowedButChosenProtocolDoesNotAllowIt_Fails Failed  484 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_OnlyTls13CipherSuiteAllowedButChosenProtocolsDoesNotAllowIt_Fails Failed 1 ms        System.PlatformNotSupportedException : CipherSuitesPolicy is not supported on this platform.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_OnlyTls13CipherSuiteAllowedOtherSideDoesNotAllowTls13_Fails Failed   < 1 ms      System.PlatformNotSupportedException : CipherSuitesPolicy is not supported on this platform.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_ThreeCipherSuitesWithTwoOverlapping_Success Failed   < 1 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.CipherSuitesPolicy_TwoCipherSuitesWithAllOverlapping_Success Failed < 1 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.NegotiatedCipherSuite_SslProtocolIsLowerThanTls13_ShouldMatchTheProtocol Failed (3) 599 ms      
System.Net.Security.Tests.NegotiatedCipherSuiteTest.NegotiatedCipherSuite_SslProtocolIsLowerThanTls13_ShouldMatchTheProtocol(protocol: Tls) Failed  555 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.NegotiatedCipherSuite_SslProtocolIsLowerThanTls13_ShouldMatchTheProtocol(protocol: Tls11) Failed    21 ms       System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.NegotiatedCipherSuite_SslProtocolIsLowerThanTls13_ShouldMatchTheProtocol(protocol: Tls12) Failed    23 ms       System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.NegotiatedCipherSuite_SslProtocolIsTls13_ShouldBeTls13 Failed   464 ms      System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
System.Net.Security.Tests.NegotiatedCipherSuiteTest.Tls13IsSupported_GetValue_ReturnsTrue Failed    < 1 ms      System.TypeInitializationException : The type initializer for 'System.Net.Security.Tests.NegotiatedCipherSuiteTest' threw an exception. ---- System.ObjectDisposedException : Cannot access a disposed object. Object name: 'SslStream'.
ServerAsyncAuthenticateTest Failed (2)  435 ms      
System.Net.Security.Tests.ServerAsyncAuthenticateTest.ServerAsyncAuthenticate_AllClientVsIndividualServerSupportedProtocols_Success(serverProtocol: Ssl3) Failed    6 ms        System.ComponentModel.Win32Exception : ํด๋ผ์ด์–ธํŠธ ๋ฐ ์„œ๋ฒ„์— ๊ณต์šฉ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— ํ†ต์‹ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
System.Net.Security.Tests.ServerAsyncAuthenticateTest.ServerAsyncAuthenticate_EachSupportedProtocol_Success(protocol: Ssl3) Failed  429 ms      System.ComponentModel.Win32Exception : ํด๋ผ์ด์–ธํŠธ ๋ฐ ์„œ๋ฒ„์— ๊ณต์šฉ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— ํ†ต์‹ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.
SslStreamEKUTest Failed (4) 30 sec      
System.Net.Security.Tests.SslStreamEKUTest.SslStream_NoEKUClientAuth_Ok Failed  34 ms       System.Security.Authentication.AuthenticationException : The remote certificate is invalid according to the validation procedure.
System.Net.Security.Tests.SslStreamEKUTest.SslStream_NoEKUServerAuth_Ok Failed  15 sec      System.TimeoutException : Task timed out after 00:00:15
System.Net.Security.Tests.SslStreamEKUTest.SslStream_SelfSignedClientEKUClientAuth_Ok Failed    15 sec      System.TimeoutException : Task timed out after 00:00:15
System.Net.Security.Tests.SslStreamEKUTest.SslStream_ServerEKUClientAuth_Fails Failed   31 ms       Assert.Throws() Failure Expected: typeof(System.IO.IOException) Actual:   typeof(System.Security.Authentication.AuthenticationException): The remote certificate is invalid according to the validation procedure. ---- System.Security.Authentication.AuthenticationException : The remote certificate is invalid according to the validation procedure.
SslStreamNetworkStreamTest Failed (1)   436 ms      
System.Net.Security.Tests.SslStreamNetworkStreamTest.SslStream_SendReceiveOverNetworkStream_AuthenticationException Failed  436 ms  category [nonfreebsdtests], category [nonnetbsdtests], category [nonosxtests], category [nonwindowstests]   Assert.Contains() Failure Not found: SSL_ERROR_SSL In value:  ํด๋ผ์ด์–ธํŠธ ๋ฐ ์„œ๋ฒ„์— ๊ณต์šฉ ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ์—†๊ธฐ ๋•Œ๋ฌธ์— ํ†ต์‹ ํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.

I'm running VS2019 16.5 P1. It's possible that there's other repositories this might be suitable for but I am not entirely sure which one it is, or if this is specific to something on this repo.

area-Infrastructure

Most helpful comment

Sorry about that, just released it:

https://www.nuget.org/packages/xunit.runner.visualstudio/2.4.2

not sure what templates need to be updated to use 2.4.2 instead of 2.4.1

All 11 comments

any idea @safern or @ViktorHofer ???

@Gnbrkm41 does this apply for ConditionalFact and ConditionalTheory or only for one of them?

Both it seems. It also happens for other attributes like PlatformSpecific.

Yes, that's the expected behavior as VS Test Explorer by default doesn't filter on traits. I started a discussion with vstest some months ago to allow specifying default included/excluded traits via the runsettings file.

@ViktorHofer do you want to close this issue then, or open is fine to have it under your radar to track the status of the discussion you're having with VS Test Explorer

Let's keep this open on our side for tracking.

Thanks @ViktorHofer -- I assigned to you since you're tracking that work.

@ViktorHofer, Has this been addressed? Looks like the tracking issue on the vstest side has been fixed.

Unfortunately not as we require an updated xunit.runner.visualstudio package: https://github.com/xunit/visualstudio.xunit/pull/205#issuecomment-625886382

cc @clairernovotny

Sorry about that, just released it:

https://www.nuget.org/packages/xunit.runner.visualstudio/2.4.2

not sure what templates need to be updated to use 2.4.2 instead of 2.4.1

Was this page helpful?
0 / 5 - 0 ratings