Skip to content

Commit 3dbdd98

Browse files
authored
Update xunit to latest, fix analyzer warnings, and update analyzer tests (#7280)
## Summary of changes - Update `xunit` to latest v2 package version (`v2.9.3`) - Update Analyzer testing libraries to the new test-framework agnostic versions - Fix all the errors xunit now flags ## Reason for change As part of the .NET 10 work we tried updating to the latest xunit. It's not _entirely_ clear if that work was actually necessary (there appeared to be a bug in preview 5 that didn't impact preview 6) but rather than waste the effort, pulling this out into a separate PR. ## Implementation details Mostly just bumping package versions. For the analyzer library changes, I followed [this guide](https://github.com/dotnet/roslyn-sdk/blob/main/src/Microsoft.CodeAnalysis.Testing/README.md) to update. For xunit I bumped required packages, and then fixed a bunch of errors the xunit.analyzers started flagging: - `Assert.Empty` -> use FluentAssertions - "Incorrect type" -> Use `int` instead of `HttpStatusCode`, `NullableBooleanTestCases` instead of `BooleanTestCases` (for example) - "Don't use `ConfigureAwait(false)`" -> Remove it (xunit has a sync context) - "xUnit1031 - Test methods should not use Blocking operations" - I _mostly_ ignored this one, because the tests are in testing for low-level stuff (call target machinery) and didn't want to change the behavior ## Test coverage This is the test. Need to double check the tests are definitely _actually_ running though... ## Other details Related to - #7170 - #7281 - https://datadoghq.atlassian.net/browse/LANGPLAT-632
1 parent 507fc6f commit 3dbdd98

File tree

70 files changed

+210
-174
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+210
-174
lines changed

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsEventBridgeTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public async Task IntegrationDisabled()
108108
var spans = await agent.WaitForSpansAsync(1, returnAllOperations: true);
109109

110110
Assert.NotEmpty(spans);
111-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
111+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
112112
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.AwsEventBridge);
113113
}
114114
}

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsS3Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public async Task IntegrationDisabled()
103103
var spans = await agent.WaitForSpansAsync(1, returnAllOperations: true);
104104

105105
Assert.NotEmpty(spans);
106-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
106+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
107107
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.AwsS3);
108108
}
109109
}

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AWS/AwsStepFunctionsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public async Task IntegrationDisabled()
115115
var spans = await agent.WaitForSpansAsync(1, returnAllOperations: true);
116116

117117
Assert.NotEmpty(spans);
118-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
118+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
119119
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.AwsStepFunctions);
120120
}
121121
}

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqlClientTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Datadog.Trace.ClrProfiler.IntegrationTests.Helpers;
1111
using Datadog.Trace.Configuration;
1212
using Datadog.Trace.TestHelpers;
13+
using FluentAssertions;
1314
using Xunit;
1415
using Xunit.Abstractions;
1516

@@ -101,7 +102,7 @@ public async Task IntegrationDisabled()
101102
var spans = await agent.WaitForSpansAsync(totalSpanCount, returnAllOperations: true);
102103

103104
Assert.NotEmpty(spans);
104-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
105+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
105106
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.SqlClient);
106107
}
107108
}

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MicrosoftDataSqliteTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Datadog.Trace.ClrProfiler.IntegrationTests.Helpers;
1414
using Datadog.Trace.Configuration;
1515
using Datadog.Trace.TestHelpers;
16+
using FluentAssertions;
1617
using VerifyXunit;
1718
using Xunit;
1819
using Xunit.Abstractions;
@@ -101,7 +102,7 @@ public async Task IntegrationDisabled()
101102
var spans = await agent.WaitForSpansAsync(totalSpanCount, returnAllOperations: true);
102103

103104
Assert.NotEmpty(spans);
104-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
105+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
105106
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.Sqlite);
106107
}
107108
}

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlCommandTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public async Task IntegrationDisabled()
7676
var spans = await agent.WaitForSpansAsync(totalSpanCount, returnAllOperations: true);
7777

7878
Assert.NotEmpty(spans);
79-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
79+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
8080
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.MySql);
8181
}
8282

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/MySqlConnectorTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Datadog.Trace.ClrProfiler.IntegrationTests.Helpers;
1111
using Datadog.Trace.Configuration;
1212
using Datadog.Trace.TestHelpers;
13+
using FluentAssertions;
1314
using Xunit;
1415
using Xunit.Abstractions;
1516

@@ -85,7 +86,7 @@ public async Task IntegrationDisabled()
8586
var spans = await agent.WaitForSpansAsync(totalSpanCount, returnAllOperations: true);
8687

8788
Assert.NotEmpty(spans);
88-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
89+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
8990
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.MySql);
9091
}
9192

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/NpgsqlCommandTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public async Task IntegrationDisabled()
110110
var spans = await agent.WaitForSpansAsync(totalSpanCount, returnAllOperations: true);
111111

112112
Assert.NotEmpty(spans);
113-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
113+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
114114
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.Npgsql);
115115
}
116116
}

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SqlCommand20Tests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading.Tasks;
99
using Datadog.Trace.Configuration;
1010
using Datadog.Trace.TestHelpers;
11+
using FluentAssertions;
1112
using Xunit;
1213
using Xunit.Abstractions;
1314

@@ -50,7 +51,7 @@ public async Task IntegrationDisabled()
5051
var spans = await agent.WaitForSpansAsync(totalSpanCount, returnAllOperations: true);
5152

5253
Assert.NotEmpty(spans);
53-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
54+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
5455
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.SqlClient);
5556
}
5657

tracer/test/Datadog.Trace.ClrProfiler.IntegrationTests/AdoNet/SystemDataSqlClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public async Task IntegrationDisabled()
135135
var spans = await agent.WaitForSpansAsync(totalSpanCount, returnAllOperations: true);
136136

137137
Assert.NotEmpty(spans);
138-
Assert.Empty(spans.Where(s => s.Name.Equals(expectedOperationName)));
138+
spans.Where(s => s.Name.Equals(expectedOperationName)).Should().BeEmpty();
139139
await telemetry.AssertIntegrationDisabledAsync(IntegrationId.SqlClient);
140140
}
141141
}

0 commit comments

Comments
 (0)