Skip to content
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

Cancelled tests not reported as failures #4196

Open
thomhurst opened this issue Nov 28, 2024 · 6 comments
Open

Cancelled tests not reported as failures #4196

thomhurst opened this issue Nov 28, 2024 · 6 comments
Labels
Area: Testing Platform Belongs to the Microsoft.Testing.Platform core library Type: Discussion

Comments

@thomhurst
Copy link
Contributor

See this run: https://github.com/thomhurst/ModularPipelines/actions/runs/12072550368/job/33666771665?pr=787#step:9:3473

Cancelled tests are marked as failures.

I'd argue they shouldn't be counted as failures as that's misleading. They haven't failed per se, they were just terminated.

If the overall test run was cancelled it should fail overall, but not each cancelled test imo.

What do you think?

@Evangelink
Copy link
Member

Is this functionally expected to have a test being cancelled? For me, it is an error even if that's the result of a user requesting cancellation.

We cannot say the test is ok as it didn't reach the end of its action.

@Evangelink Evangelink added Type: Discussion Area: Testing Platform Belongs to the Microsoft.Testing.Platform core library and removed Needs: Triage 🔍 labels Nov 29, 2024
@thomhurst
Copy link
Contributor Author

We cannot say the test is ok as it didn't reach the end of its action.

This is similar to #3699 I think.
It's more inconclusive than failed. If the test framework marks then as cancelled, I'd say it's inconclusive. If it didn't cancel, it might have passed, or it might have failed, we don't know.

The overall run should still fail, but it can create noise in the logs or test explorer when trying to find actual failures.

@thomhurst
Copy link
Contributor Author

My use case is I have exposed a --fail-fast flag in TUnit. So if you've got a large test suite that takes ages to run, there's the option to fail quickly on the first failure. The first failure will cancel the test session's cancellation token, and so all pending tests would then be marked as cancelled. Sifting through the output/test explorer to find that failure is harder if all the cancellations look like failures too.

@Evangelink
Copy link
Member

I understand the TE situation, let's put it on the side for a second to focus on CLI experience, what would be your expectations there?

@thomhurst
Copy link
Contributor Author

Personally I wouldn't count them under the failure counter, and I find the stacktrace clutter that makes real failures harder to find

E.g.

failed (canceled) Has_Not_Errored (0ms)
System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at TUnit.Engine.Framework.TUnitTestFramework.ExecuteRequestAsync(ExecuteRequestContext context)
failed Unhandled exception - TaskCanceledException: A task was canceled. (0ms)
  System.Threading.Tasks.TaskCanceledException: A task was canceled.
    at TUnit.Engine.Framework.TUnitTestFramework.ExecuteRequestAsync(ExecuteRequestContext context)

@nohwnd
Copy link
Member

nohwnd commented Dec 2, 2024

Sounds reasonable to me to not report it as error (there is no additional info in the error anyway?) as long as we guarantee that the whole run will finish with error code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Testing Platform Belongs to the Microsoft.Testing.Platform core library Type: Discussion
Projects
None yet
Development

No branches or pull requests

3 participants