如何使一组测试仅作为有序测试运行?

发布于 2024-10-09 13:14:55 字数 401 浏览 0 评论 0原文

我从未做过有序测试,因为我相信这不是一个好的做法。 在我工作的地方,我被告知要这样做,所以让我们抛开什么是好的或坏的做法。

我是 msTests 的新手,所以你能在这里帮助我吗?

我有 10 个测试,必须按特定顺序运行,否则其中一些会失败。

  1. 我创建了一个基本测试类并添加了所有 10 个测试。
  2. 我创建了一个有序测试,并按照我想要执行它们的顺序移动到右侧。一切都很好。
  3. 运行测试,但 MsTest 运行测试两次。一旦订购的测试全部成功!但也以不特定的顺序运行相同的测试,

如果我有一组按顺序排列的测试,我是否错过了明显的情况,不应该将这些测试删除,因为正常测试仅作为有序测试运行。

如何使一组测试仅作为有序测试运行?

有什么建议吗?

I have never done ordered tests as I am of the beleif that it's not good practice.
Where I work I am told to do them ,so let's cast aside what's good or bad practice.

I am new to msTests so could you help me here.

I have 10 tests and have to run in a particular order or some of them will fail.

  1. I have created a Basic test class and added all the 10 tests.
  2. I have created an Ordered test and moved to the right in the order I want to execute them.All fine.
  3. Run the tests but MsTest runs the tests twice.Once the ordered tests all successed!! But also runs the same tests in no particular order

Am I missing the obvious if I have a set of tests that are in order shouldnt those be removed as normal tests only run as ordered test.

How can I make a set of tests only run as ordered tests?

Any suggestions?

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

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

发布评论

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

评论(4

浴红衣 2024-10-16 13:14:55

我也遇到过这个问题,但后来我在 MSDN 上找到了以下文档:
有序测试概述

显然您不知道在测试视图中以正确的顺序获取测试列表。
相反,有序测试显示为单个测试。

对我来说这不是一个好消息,因为当我选择“在解决方案中运行所有测试”时,我的测试将运行两次(当以错误的顺序运行时第二次失败),但至少我得到了原因的解释它就是这样表现的。

I too struggled with this one, but then I found the following documentation on MSDN:
Ordered Test Overview

Apparently you don't get a list of the tests in the right order in the Test View.
Instead the ordered test appears as a single test.

To me this was not a very good news as my tests will be run twice when I choose to "Run All Tests In Solution" (and fail the second time when run in the wrong order), but at least I got an explanation to why it is behaving this way.

戴着白色围巾的女孩 2024-10-16 13:14:55

在 VSTS 中,每当您创建有序测试时,它实际上都会为该测试创建一个单独的文件。因此,在执行时您只需要执行该命令的测试文件。它将包括按特定顺序进行的所有测试和测试。在执行过程中,它只会按照它运行。

In VSTS, whenever you create an ordered test, it actually creates a separate file for that test. So, while executing you need to execute that ordered test file only. It will include all the tests in a particular order & during execution it will run as according to it only.

策马西风 2024-10-16 13:14:55

这是一个很受欢迎的问题(尽管我同意,但这是非常糟糕的做法)。看看这个问题:

MSTEST/Visual Studio 2008 团队测试如何决定测试方法执行顺序?

我自己没有这样做过,因此不能保证上述问题中的任何答案都有效,但值得一试。

This is a popular question (though I agree, it's very bad practise). Check out this SO question:

How Does MSTEST/Visual Studio 2008 Team Test Decide Test Method Execution Order?

I've not done this myself, so cannot guarantee that any of the answers in the above question worked, but it's worth a shot.

请持续率性 2024-10-16 13:14:55

这可能是一个老话题了,但在 Google 上搜索时,这个问题确实会出现在第一页上。我认为您正在寻找的是播放列表。创建一个新的测试播放列表,然后仅添加您要运行的测试。

This may be an old topic to answer, but this question does come up on the first page when searching on Google. I think what you are looking for is a Playlist. Create a new test playlist and then add only the tests you want to run.

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