在 Visual Studio 2022 中运行 QUnit 测试脚本时出现异常

问题描述 投票:0回答:1

当我尝试在 Visual Studio 2022 中为 JavaScript 文件运行 QUnit 测试脚本时遇到问题。抛出的错误消息如下:

System.ArgumentException:指定的参数不能为空。参数名称:过滤器

我已在下面的代码块中包含了异常的完整堆栈跟踪。有人可以提供如何解决此问题的帮助吗?

Executing all tests in file: Main.testfile-test.js
System.ArgumentException: The specified argument cannot be empty.
Parameter name: filters
   at Microsoft.VisualStudio.TestWindow.Extensibility.ValidateArg.NotNullOrEmpty[T](IEnumerable`1 arg, String parameterName)
   at Microsoft.VisualStudio.TestWindow.Controller.TestContainerConfigurationQueryBySolutionContext.<GetTestContainerConfigurationsInternalAsync>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.TestContainerConfigurationQuery.<GetTestContainerConfigurationsAsync>d__18.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.TestRunConfiguration.<UpdateAfterTestDiscoveryAsync>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RunOperation.<RunTestsAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.TestWindow.Controller.RunOperation.<RunTestsAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Microsoft.VisualStudio.TestWindow.Controller.RunOperation.<RunTestsAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RunOperation.<ExecuteInternalAsync>d__23.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<<ExecuteAsync>b__43_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Logging.ILoggerExtensions.<CallWithCatchAsync>d__11`1.MoveNext()```
javascript visual-studio unit-testing qunit chutzpah
1个回答
0
投票

一般答案

我认为有时可能是由于测试文件或正在测试的 javascript 中存在某种错误。然而,在我的具体情况下,似乎底层技术之一正在强加任意变量名称长度。

我的经历

我正在使用 Chutzpah(VSIX 扩展)来执行 QUnit 测试。当我第一次加载我的解决方案时,测试在

Test Explorer
中按预期显示,但在我对几个 Qunit 测试文件进行了一些新修改后,我注意到除了其中一个之外,所有这些文件仍在工作。

我尝试使用 Chutzpah 提供的右键单击上下文菜单直接调用脚本文件的测试,并得到与 OP 报告的相同错误

我注意到,当我将测试恢复到原始状态时,丢失的测试文件再次出现在我的

Test Explorer
中。我开始慢慢地将我的编辑重新引入测试中..直到..哇..它再次消失了。

我现在对触发问题的最佳猜测是变量名太长。很奇怪吧?

重大改变:

var myEquipmentModValidationMsg = '';//existing var

//new vars
var myEquipmentModPromptedUserToSetServicesCheckbox = false;
var myEquipmentModIsNoLongerPromptingUserToSetServicesCheckbox = false;

可接受的改变:

var myEquipmentModValidationMsg = '';//existing var

//new vars
var promptedUserToSetServicesCheckbox = false;
var noLongerPrompting = false;
据我所知,变量名长度截止为 42 个字符。据我所知,ECMA 标准在这里不起作用,因为我发现没有提到这样的限制。也许是厚颜无耻的事情?

© www.soinside.com 2019 - 2024. All rights reserved.