You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reporting entry point stack traces would make the test assertion message significantly more useful in the case where you aren't sure where or why you should be adding AmbientTasks.WaitAllAsync(); to your test:
The test started ambient tasks but did not wait for them.
using System;using NUnit.Framework;using NUnit.Framework.Interfaces;using Techsola;[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]publicsealedclassWaitForAmbientTasksAttribute:Attribute,ITestAction{publicActionTargetsTargets=> ActionTargets.Test;publicvoidBeforeTest(ITesttest){
AmbientTasks.BeginContext();}publicvoidAfterTest(ITesttest){switch(TestContext.CurrentContext.Result.Outcome.Status){case TestStatus.Failed:case TestStatus.Inconclusive:case TestStatus.Skipped:return;}vartask= AmbientTasks.WaitAllAsync();if(!task.IsCompleted) Assert.Fail("The test started ambient tasks but did not wait for them.");
task.GetAwaiter().GetResult();}}
The text was updated successfully, but these errors were encountered:
jnm2
changed the title
Enable tests to report the stack tracks of AmbientsTasks entry points for incomplete tasks
Enable tests to report the stack traces of AmbientsTasks entry points for incomplete tasks
Apr 30, 2020
Reporting entry point stack traces would make the test assertion message significantly more useful in the case where you aren't sure where or why you should be adding
AmbientTasks.WaitAllAsync();
to your test:The text was updated successfully, but these errors were encountered: