Skip to content
This repository was archived by the owner on May 27, 2026. It is now read-only.

fix: add assertion to ParallelCakeEngineTests.Should_Swallow_Exceptions_If_ContinueOnError_Is_Set#2

Open
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260527-130111-751448d2
Open

fix: add assertion to ParallelCakeEngineTests.Should_Swallow_Exceptions_If_ContinueOnError_Is_Set#2
sonarqube-agent[bot] wants to merge 1 commit into
masterfrom
remediate-master-20260527-130111-751448d2

Conversation

@sonarqube-agent
Copy link
Copy Markdown

This PR was automatically created by the Remediation Agent's Scheduled backlog remediation feature.

Added an assertion to verify that no exception is thrown when ContinueOnError is set, fixing a SonarQube blocker issue that required all test cases to contain at least one assertion. This ensures the test properly validates the expected behavior of exception swallowing.

View Project in SonarCloud


Fixed Issues

csharpsquid:S2699 - Add at least one assertion to this test case. • BLOCKERView issue

Location: src/Cake.Parallel.Tests/ParallelCakeEngineTests.cs:309

Why is this an issue?

The rule targets test methods that lack an assertion and consist solely of an action and, optionally, a setup.

What changed

This hunk fixes the test method 'Should_Swallow_Exceptions_If_ContinueOnError_Is_Set' which previously had no assertions. The original code simply called await engine.RunTargetAsync(...) without verifying any behavior. The fix wraps the call in Record.ExceptionAsync to capture any thrown exception, and then adds Assert.Null(record) to explicitly assert that no exception was thrown. This satisfies the static analysis rule requiring at least one assertion in every test method, ensuring the test meaningfully validates that exceptions are swallowed when ContinueOnError is set.

--- a/src/Cake.Parallel.Tests/ParallelCakeEngineTests.cs
+++ b/src/Cake.Parallel.Tests/ParallelCakeEngineTests.cs
@@ -316,2 +316,6 @@ namespace Cake.Parallel.Tests
-                // When, Then
-                await engine.RunTargetAsync(fixture.Context, fixture.ExecutionStrategy, "A");
+                // When
+                var record = await Record.ExceptionAsync(async () =>
+                    await engine.RunTargetAsync(fixture.Context, fixture.ExecutionStrategy, "A"));
+
+                // Then
+                Assert.Null(record);

Have a suggestion or found an issue? Share your feedback here.


SonarQube Remediation Agent uses AI. Check for mistakes.

Fixed issues:
- AYfoIGTKqfEBxbAAXPMw for csharpsquid:S2699 rule

Generated by SonarQube Agent (task: 470ab8c1-12a4-44ce-9f70-1ed3355c6c24)
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Development

Successfully merging this pull request may close these issues.

1 participant