问题在SpecFlow生成的剧作作者测试上手动调用DotNet测试

发布于 2025-02-04 21:34:57 字数 871 浏览 4 评论 0原文

我正在研究一个C#项目,该项目正在使用Specflow与Playwright一起处理我们的大多数测试,并且我正在尝试设置一种仅用于失败的测试的playwright跟踪文件的方法。现在,我正在打印每个测试的名称,该名称失败了.txt文件,然后在我们的测试运行结束时,使用playwright Trace Generative在该文件中使用Shell脚本在该文件中的每个测试中手动调用dotnet测试。对于具有简单名称的测试,例如“ FillinallfieldsonPage”,这很好,但是如果使用示例从方案概述中生成的测试失败,则会给我带来错误。我相信这是由于DotNet测试解析测试名称的方式,因为SpecFlow以

CheckSortingAndDataInHoverMenu("C, User",null)

“ C,用户”是场景概述提供的示例之一。我尝试添加一条将字符串重新格式化的行更符合我在其他地方的推荐,以使最终结果看起来像这样:

CheckSortingAndDataInHoverMenu(\"C%2C User\"%2Cnull)

但是我仍然会收到以下错误:

Running dotnet test on "CheckSortingAndDataInHoverMenu(\"C%2C User\"%2Cnull)"
MSBUILD : error MSB1009: Project file does not exist.
Switch: User"%2Cnull)

我已经验证了.csproj文件确实存在,并且可以从该命令运行其他测试,因此我知道它是从正确的目录调用的。看起来Dotnet测试认为“用户”%2cnull)是一个.csproj文件的名称,它正在以ARG为ARG,我不知道如何使其正确处理完整的测试名称。

I'm working on a C# project that's using specflow with playwright to handle most of our testing, and I'm trying to set up a way to generate playwright trace files only for tests that have failed. Right now I'm printing the name of each test that fails to a .txt file, then using a shell script to manually call dotnet test on each test in that file at the end of our test run with playwright trace generation enabled. This works fine for tests that have a simple name, such as "FillInAllFieldsOnPage", but if a test that is generated from a scenario outline using examples fails it gives me an error. I believe this is due to the way that dotnet test is parsing the name of the test, as specflow generates the name in the format

CheckSortingAndDataInHoverMenu("C, User",null)

where "C, User" is one of the examples given to the Scenario Outline. I've tried adding a line that reformats the string to be more in line with what I've seen recommended elsewhere, so that the end result looks like this:

CheckSortingAndDataInHoverMenu(\"C%2C User\"%2Cnull)

but I still get the following error:

Running dotnet test on "CheckSortingAndDataInHoverMenu(\"C%2C User\"%2Cnull)"
MSBUILD : error MSB1009: Project file does not exist.
Switch: User"%2Cnull)

I've verified that the .csproj file does exist, and other tests are able to be run from that command so I know it's being called from the correct directory. It looks like dotnet test thinks that "User"%2Cnull)" is a name for a .csproj file that I'm passing it as an arg, and I don't know how to get it to properly process the full test name.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里南柯 2025-02-11 21:34:57

我发现的解决方案是简单地删除括号中的测试名称的一部分,这导致dotnet test命令以匹配名称运行每个测试。然后,我在生成的每个测试跟踪的名称中添加了一个随机的GUID,以防止它们互相覆盖。

The solution I found to this was to simply remove the part of the test name in parenthesis, which caused the dotnet test command to run every test with a matching name. I then added a random guid to the name of each test trace that was generated in order to prevent them from overwriting eachother.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文