Uh oh!
There was an error while loading. Please reload this page.
Enable xunit1024 - #34512
Conversation
The very next method is a Theory with inline data that tests this exact scenario.
danmoseley
commented
Apr 3, 2020
Looks like there are some more instances to fix, in different configurations. |
stephentoub
commented
Apr 3, 2020
This is only fixing occurrences in System.Text.Json. Presumably there are others in many other test projects? Or is Json really the only one? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
alexvy86
commented
Apr 3, 2020
Right, I've only looked at netcoreapp, I'll address net472 hopefully during the weekend.
I was expecting to find more, and my intention with the PR was to fix them all... but I just rebuilt all of the libraries subcategory after fixing |
alexvy86
commented
Apr 3, 2020
Nvm, I built the libraries themselves, not their test projects, which are the ones with issues; now I'm seeing more errors. So yeah, I'll keep working on the rest of the test projects. |
For RemoveNonExistingTest, just moved the logic from the single-use helper into the method with the Fact attribute.
In Math.cs, removed Round_Decimal_Digits Fact which manually tested cases included in the MemberData of a Theory with the same name.
Theory EndInit_ResumesPausedEnableRaisingEvents alredy tests the same scenario as the removed Fact of the same name.
| [Fact] | ||
| public async Task CompressDecompress_RoundTrip() | ||
| public async Task CompressDecompress_RoundTrip_BaseTests() |
There was a problem hiding this comment.
I'd prefer to see this test's name left as-is, and the method it delegates to instead be renamed to something like CompressDecompress_RoundTrip_OuterLoop. Same goes for the other similar cases here. My reason is "BaseTests" doesn't really speak to what the test is doing, plus this is the test that runs 99% of the time, and the one it delegates to is relegated to only running when we run "OuterLoop".
| [InlineData("", "", StringComparison.OrdinalIgnoreCase, true)] | ||
| [InlineData("", "a", StringComparison.OrdinalIgnoreCase, false)] | ||
| public static void EndsWith(string s, string value, StringComparison comparisonType, bool expected) | ||
| public static void EndsWith_ExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) |
There was a problem hiding this comment.
| publicstaticvoidEndsWith_ExplicitComparisonType(strings,stringvalue,StringComparisoncomparisonType,boolexpected) | |
| publicstaticvoidEndsWith_StringComparison(strings,stringvalue,StringComparisoncomparisonType,boolexpected) |
| [InlineData("", "", StringComparison.OrdinalIgnoreCase, true)] | ||
| [InlineData("", "hello", StringComparison.OrdinalIgnoreCase, false)] | ||
| public static void StartsWith(string s, string value, StringComparison comparisonType, bool expected) | ||
| public static void StartsWith_WithExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) |
There was a problem hiding this comment.
| publicstaticvoidStartsWith_WithExplicitComparisonType(strings,stringvalue,StringComparisoncomparisonType,boolexpected) | |
| publicstaticvoidStartsWith_StringComparison(strings,stringvalue,StringComparisoncomparisonType,boolexpected) |
| [Fact] | ||
| public static void ToLower() | ||
| public static void ToLower_2() |
There was a problem hiding this comment.
What is the other ToLower test this is conflicting with? "ToLower_2" isn't descriptive about what makes this test different from a presumed "ToLower_1", so we should either pick descriptive names or combine the tests.
There was a problem hiding this comment.
It's this one, using strings + Span instead of char[] + Span throughout. How about naming them ToLower_String and ToLower_CharArray?
There was a problem hiding this comment.
How about naming them ToLower_String and ToLower_CharArray?
Sounds fine. Thanks.
| [Fact] | ||
| public static void ToUpper() | ||
| public static void ToUpper_2() |
Uh oh!
There was an error while loading. Please reload this page.
| [Theory] | ||
| [MemberData(nameof(EqualsData))] | ||
| public void Equals(ImmutableArray<int> first, ImmutableArray<int> second, bool expected) | ||
| public void EqualsBaseTest(ImmutableArray<int> first, ImmutableArray<int> second, bool expected) |
There was a problem hiding this comment.
Elsewhere you used EqualsTest. Why EqualsBaseTest here?
There was a problem hiding this comment.
I thought it had been because of some class that inherited from this and had its own EqualsTest, but apparently it's not the case here, I'll simplify to EqualsTest.
Uh oh!
There was an error while loading. Please reload this page.
| [Fact] | ||
| public void Ctor_ThrownException_GetFramesReturnsExpected() | ||
| { | ||
| // TODO: is this test redundant? See Ctor_ThrownException_GetFramesReturnsExpected_2 below |
There was a problem hiding this comment.
It's not redundant, it's testing a different StackTrace constructor.
There was a problem hiding this comment.
Good point, I'll remove the comment
| [InlineData(true)] | ||
| [InlineData(false)] | ||
| public void Ctor_ThrownException_GetFramesReturnsExpected(bool fNeedFileInfo) | ||
| public void Ctor_ThrownException_GetFramesReturnsExpected_2(bool fNeedFileInfo) |
There was a problem hiding this comment.
| publicvoidCtor_ThrownException_GetFramesReturnsExpected_2(boolfNeedFileInfo) | |
| publicvoidCtor_Bool_ThrownException_GetFramesReturnsExpected(boolfNeedFileInfo) |
Uh oh!
There was an error while loading. Please reload this page.
| [Fact] | ||
| public Task ManyConcurrentWriteAsyncs() | ||
| public Task ManyConcurrentWriteAsyncs_BaseTest() |
There was a problem hiding this comment.
Same feedback as in a previous similar case... let's leave this one as ManyConcurrentWriteAsyncs, and change the one below to ManyConcurrentWriteAsyncs_OuterLoop.
| [Theory] | ||
| [MemberData(nameof(TestData))] | ||
| public void Any(IEnumerable<int> source, bool expected) | ||
| public void AnyTest(IEnumerable<int> source, bool expected) |
There was a problem hiding this comment.
This should stay Any, and the test below should be changed to be Any_Predicate, or something like that.
| [InlineData("Hello", 'E', StringComparison.OrdinalIgnoreCase, true)] | ||
| [InlineData("", 'H', StringComparison.OrdinalIgnoreCase, false)] | ||
| public static void Contains(string s, char value, StringComparison comparisionType, bool expected) | ||
| public static void Contains_Char_ExplicitComparisonType(string s, char value, StringComparison comparisionType, bool expected) |
There was a problem hiding this comment.
| publicstaticvoidContains_Char_ExplicitComparisonType(strings,charvalue,StringComparisoncomparisionType,boolexpected) | |
| publicstaticvoidContains_Char_StringComparison(strings,charvalue,StringComparisoncomparisionType,boolexpected) |
| [InlineData("Hello", "ell" + SoftHyphen, StringComparison.OrdinalIgnoreCase, false)] | ||
| [InlineData("Hello", "Ell" + SoftHyphen, StringComparison.OrdinalIgnoreCase, false)] | ||
| public static void Contains(string s, string value, StringComparison comparisonType, bool expected) | ||
| public static void Contains_String_ExplicitComparisonType(string s, string value, StringComparison comparisonType, bool expected) |
There was a problem hiding this comment.
| publicstaticvoidContains_String_ExplicitComparisonType(strings,stringvalue,StringComparisoncomparisonType,boolexpected) | |
| publicstaticvoidContains_String_StringComparison(strings,stringvalue,StringComparisoncomparisonType,boolexpected) |
| [Fact] | ||
| public static void VerifyDefaults() | ||
| { | ||
| static void verifyDefaults(Rijndael alg) |
There was a problem hiding this comment.
In situations like this, where the test method differs from the local function by the casing of a single letter, it'd be really easy to accidentally get a stack overflow or an infinite loop by calling the wrong thing. Could you rename such local functions to something a little more different?
There was a problem hiding this comment.
Sure, I actually started using test for the local function at some point, I missed updating some of the ones I did earlier.
| } | ||
| private void HmacMustBeMultipleOfEightBits(int bits) | ||
| [Fact(Skip = "https://github.com/dotnet/runtime/issues/20429")] |
There was a problem hiding this comment.
Nit: as long as you're changing this, can you make it instead be:
[ActiveIssue("https://github.com/dotnet/runtime/issues/20429")][Fact]?
| } | ||
| [Fact] | ||
| public static void ReadKeyValuePairOfKeyValuePair() |
There was a problem hiding this comment.
Was this a dup? Wondering why it's being deleted.
There was a problem hiding this comment.
Yes, see the first bullet point of the second set in the description, there's a Theory testing the exact same thing, and the data that this method uses is already part of the InlineData of the Theory.
stephentoub
left a comment
There was a problem hiding this comment.
Thanks for cleaning all this up!
alexvy86
commented
Apr 8, 2020
The check failures don't seem related to the changes, right? Is it possible to retrigger only the failed builds? |
stephentoub
commented
Apr 8, 2020
Thanks! |
There's a couple of recurring patterns in this PR:
Factthat does nothing but call a helper method with different parameter values, with aTheorythat usesInlineData(or just "inline" the redundant method, if there was only one call).Fact/Theorymethod, with a local function.I'll make particular notes about changes that do not fall in one of the above patterns, or other comments, for easier review:
src/libraries/System.Text.Json/tests/Serialization/Value.ReadTests.GenericCollections.csReadKeyValuePairOfKeyValuePairFactsince theTheoryright after it already covers that case. The code is identical, and the inline data for theTheoryalready includes the value that theFactused.src/libraries/System.Private.Xml/tests/XmlSerialize/XmlSerializerTests.RuntimeOnly.csXml_GuidAsRoot_HelperandXml_ListGenericRoot_Helperwere just renames, but I noticed that they don't use their only parameter so maybe there's a problem there. To be handled in a separate issue if they actually are.src/libraries/System.Diagnostics.StackTrace/tests/StackTraceTests.csCtor_ThrownException_GetFramesReturnsExpectedmight be redundant? Depending on the default value thatfNeedFileInfogets when instantiating aStackTrace, but I couldn't easily find where to check that.Will fix#34503