-
Notifications
You must be signed in to change notification settings - Fork 4
test(refactor): improve code coverage #635
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 47 commits
4a5750d
55867eb
df1886c
e51072f
da87546
ca2f3bc
0bc2ba6
63d39b6
774d2b2
a89a5d2
368dffc
2e85b52
59bf028
2067433
bc5e21f
50267de
30c9fce
7a2df5c
af00375
e928265
48662fd
26347b2
c284cc5
351b6c3
a260489
3114a71
656e0b4
ca0aa8b
afebfd9
50024c5
b7fb7a9
ea9b2f5
b474f53
43024eb
8059df2
87937b2
8f321e0
93bc5a2
3a543bc
39c3999
cabb69e
00049eb
ada8199
5632bf2
9dccdc1
930c720
072a688
56775f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -259,13 +259,18 @@ ci(workflow): add performance testing to nightly builds | |||||||||||||||||||||
| Run all unit tests: | ||||||||||||||||||||||
| `dotnet test --settings ./build/targets/tests/test.runsettings` | ||||||||||||||||||||||
| All tests must pass. PRs with failing tests will be closed. | ||||||||||||||||||||||
| - **Code Coverage:** | ||||||||||||||||||||||
| Code coverage is generated automatically if you use the `test.runsettings` from above, which produces Cobertura format. If you wish to have a different format, you can specify on the command line. Example: | ||||||||||||||||||||||
| `dotnet test --collect:"XPlat Code Coverage" --settings ./build/targets/tests/test.runsettings` | ||||||||||||||||||||||
| PRs must not reduce coverage for critical paths without justification. | ||||||||||||||||||||||
| - **Codacy Analysis:** | ||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Excellent formalization of code coverage requirements! The addition of code coverage as a mandatory workflow requirement properly reinforces the project's commitment to comprehensive test coverage. The explanation of automatic generation via test settings is helpful for developers. Consider a minor formatting improvement for consistency: -- **Code Coverage:**
- Code coverage is generated automatically if you use the `test.runsettings` from above, which produces Cobertura format. If you wish to have a different format, you can specify on the command line. Example:
+- **Code Coverage:**
+ Code coverage is generated automatically when using the `test.runsettings` file above, producing Cobertura format. For different formats, specify via command line:📝 Committable suggestion
Suggested change
🧰 Tools🪛 LanguageTool[grammar] ~263-~263: Use the right pronoun (QB_NEW_EN_OTHER_ERROR_IDS_9) [grammar] ~263-~263: There might be a mistake here. (QB_NEW_EN_OTHER) 🤖 Prompt for AI Agents |
||||||||||||||||||||||
| Run Codacy CLI analysis on all changed files. Fix all reported issues before submitting the PR. | ||||||||||||||||||||||
| - **Evidence Required:** | ||||||||||||||||||||||
| PR description must include console output or screenshots for: | ||||||||||||||||||||||
| - `dotnet format` | ||||||||||||||||||||||
| - `dotnet build` | ||||||||||||||||||||||
| - `dotnet test` | ||||||||||||||||||||||
| - **Code coverage report summary** | ||||||||||||||||||||||
| - Codacy analysis (if issues were found and fixed) | ||||||||||||||||||||||
| - **No Received Files:** | ||||||||||||||||||||||
| Remove any `*.received.*` files before committing. | ||||||||||||||||||||||
|
|
@@ -639,16 +644,18 @@ Before submitting a PR, ensure: | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| **What Constitutes Validation Evidence:** | ||||||||||||||||||||||
| - Test execution logs showing all tests pass | ||||||||||||||||||||||
| - **Code coverage report summary and/or screenshots showing coverage for changed code** | ||||||||||||||||||||||
| - Performance benchmark results (if applicable) | ||||||||||||||||||||||
| - Screenshots of successful CI runs | ||||||||||||||||||||||
| - Manual testing results for UI changes | ||||||||||||||||||||||
| - Code coverage reports for new features | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| **Evidence Format:** | ||||||||||||||||||||||
| - Include logs, screenshots, or links to CI runs | ||||||||||||||||||||||
| - Provide clear, readable evidence | ||||||||||||||||||||||
| - Ensure evidence is recent and relevant | ||||||||||||||||||||||
| - Link to specific test results or benchmarks | ||||||||||||||||||||||
| - Link to specific test results, code coverage reports, or benchmarks | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| **MANDATORY:** Always validate code coverage after making code or test changes. Code coverage validation is a required step before yielding, submitting, or completing any task. Coverage must be reported as part of the validation evidence in PRs and reviews. | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| ### Evidence of Moq Version Awareness | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,4 @@ | ||
| using Microsoft.CodeAnalysis.Operations; | ||
| using Moq.Analyzers.Common; | ||
|
|
||
| namespace Moq.Analyzers; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using Microsoft.CodeAnalysis.Operations; | ||
|
|
||
| namespace Moq.Analyzers; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| namespace Moq.Analyzers.Test.Common; | ||
|
Check warning on line 1 in tests/Moq.Analyzers.Test/Common/DiagnosticExtensionsTests.cs
|
||
|
|
||
| public class DiagnosticExtensionsTests | ||
| { | ||
| [Fact] | ||
| public void CreateDiagnostic_FromSyntaxNode_Basic() | ||
| { | ||
| SyntaxTree tree = CSharpSyntaxTree.ParseText("class C { void M() {} }"); | ||
| SyntaxNode root = tree.GetRoot(); | ||
| DiagnosticDescriptor rule = new DiagnosticDescriptor("TEST0001", "Test", "Test message", "Test", DiagnosticSeverity.Warning, true); | ||
| Diagnostic diag = root.CreateDiagnostic(rule); | ||
| Assert.Equal("TEST0001", diag.Id); | ||
| Assert.Equal(DiagnosticSeverity.Warning, diag.Severity); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateDiagnostic_FromLocation_WithProperties() | ||
| { | ||
| SyntaxTree tree = CSharpSyntaxTree.ParseText("class C { void M() {} }"); | ||
| Location loc = tree.GetRoot().GetLocation(); | ||
| DiagnosticDescriptor rule = new DiagnosticDescriptor("TEST0002", "Test2", "Test message 2", "Test", DiagnosticSeverity.Info, true); | ||
| ImmutableDictionary<string, string?> properties = ImmutableDictionary<string, string?>.Empty.Add("Key", "Value"); | ||
| Diagnostic diag = loc.CreateDiagnostic(rule, properties); | ||
| Assert.Equal("TEST0002", diag.Id); | ||
| Assert.Equal("Value", diag.Properties["Key"]); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateDiagnostic_FromOperation_DelegatesToSyntax() | ||
| { | ||
| SyntaxTree tree = CSharpSyntaxTree.ParseText("class C { void M() {} }"); | ||
| SyntaxNode root = tree.GetRoot(); | ||
| CSharpCompilation compilation = CSharpCompilation.Create("Test", new[] { tree }); | ||
| SemanticModel model = compilation.GetSemanticModel(tree); | ||
| MethodDeclarationSyntax methodDecl = root.DescendantNodes().OfType<MethodDeclarationSyntax>().First(); | ||
|
rjmurillo marked this conversation as resolved.
|
||
| Microsoft.CodeAnalysis.IOperation? operation = model.GetOperation(methodDecl); | ||
| DiagnosticDescriptor rule = new DiagnosticDescriptor("TEST0003", "Test3", "Test message 3", "Test", DiagnosticSeverity.Error, true); | ||
| Diagnostic diag = operation!.CreateDiagnostic(rule); | ||
| Assert.Equal("TEST0003", diag.Id); | ||
| Assert.Equal(DiagnosticSeverity.Error, diag.Severity); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void CreateDiagnostic_FromOperation_WithProperties() | ||
| { | ||
| SyntaxTree tree = CSharpSyntaxTree.ParseText("class C { void M() {} }"); | ||
| SyntaxNode root = tree.GetRoot(); | ||
| CSharpCompilation compilation = CSharpCompilation.Create("Test", new[] { tree }); | ||
| SemanticModel model = compilation.GetSemanticModel(tree); | ||
| MethodDeclarationSyntax methodDecl = root.DescendantNodes().OfType<MethodDeclarationSyntax>().First(); | ||
| Microsoft.CodeAnalysis.IOperation? operation = model.GetOperation(methodDecl); | ||
| DiagnosticDescriptor rule = new DiagnosticDescriptor("TEST0004", "Test4", "Test message 4", "Test", DiagnosticSeverity.Warning, true); | ||
| ImmutableDictionary<string, string?> properties = ImmutableDictionary<string, string?>.Empty.Add("Key2", "Value2"); | ||
| Diagnostic diag = operation!.CreateDiagnostic(rule, properties); | ||
| Assert.Equal("TEST0004", diag.Id); | ||
| Assert.Equal("Value2", diag.Properties["Key2"]); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.