如何在 MSpec 中对测试进行分组?

发布于 2024-10-21 18:19:31 字数 481 浏览 4 评论 0原文

你能帮我解决我的问题吗?

我正在做一个项目。对于测试,我使用 MSpec。 是否可以分组测试。所以当我运行测试运行程序时,他们应该按组进行测试 即正确的方法:

1)注册用户时,我提供不同的密码,确认密码

  • 应返回错误消息

2)注册用户时,我提供所有需要的信息 » 用户应该注册 » 用户应该被重定向到主页

3)当获取标签树时,我得到标签树,

  • 我们应该看到标签树

但在我的情况下,它的工作原理如下:

1)注册用户时,我提供不同的密码,确认密码

  • 应该返回错误消息

3 )当获取标签树时,我得到标签树,

  • 我们应该看到标签树

2)注册用户时,我提供所有需要的信息

  • 用户应该注册
  • 用户应该重定向到主页

Could you help me please with my problem.

I am working on a project. For tests I use MSpec.
Is it possible to group test. So when I run test runner they should be tested by groups
i.e. for proper way:

1) When registering user, I provide different password and confirmation password

  • should return error message

2) When registering user, I provide all needed information
» user should be registered
» user should be redirected to home page

3) When getting tags tree, I get tags tree

  • we should see tags tree

But in my case it works like:

1) When registering user, I provide different password and confirmation password

  • should return error message

3) When getting tags tree, I get tags tree

  • we should see tags tree

2) When registering user, I provide all needed information

  • user should be registered
  • user should be redirected to home page

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

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

发布评论

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

评论(1

神回复 2024-10-28 18:19:31

目前唯一对上下文进行分组的位置是在 HTML 报告中。您需要使用 [Subject] 属性,并为需要分组的上下文提供相同的文本或类型名称。

在一个不相关的注释中,我会以不同的方式命名您的上下文/规范:

User registration, When providing different password and confirmation password
  » should display an error message

User registration, When providing all information needed (What's "all" information?)
  » should register the user
  » should redirect to the home page

Tags tree, When getting the tags tree
  » should display the tags tree

The only place contexts are grouped right now is in the HTML report. You need to use the [Subject] attribute and provide the same text or type name for contexts that need to be grouped.

On an unrelated note, I would name your contexts/specifications differently:

User registration, When providing different password and confirmation password
  » should display an error message

User registration, When providing all information needed (What's "all" information?)
  » should register the user
  » should redirect to the home page

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