在 Team Foundation Server (TFS) 版本上运行单元测试

发布于 2024-07-09 01:04:49 字数 146 浏览 4 评论 0原文

当给定的构建运行时,让 Team Foundation Server 运行单元测试的步骤是什么?

首次设置 TFS 服务器以执行此操作时,开发人员或系统管理员应注意哪些警告/陷阱/解决方法?

构建期间单元测试问题的常见故障排除步骤有哪些?

What are the steps to get Team Foundation Server running unit tests when a given build runs?

What are the caveats / pitfalls / workarounds a dev or sysadmin should be aware of when setting up a TFS server to do this for the first time?

What are common troubleshooting steps for unit test problems during builds?

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

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

发布评论

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

评论(3

贵在坚持 2024-07-16 01:04:49

这取决于您运行的 TFS 版本,因此我假设它是 2008 年。

首先,您必须在计算机上安装 Team Edition for Testers,它将充当您的构建代理,如 如何:创建构建定义

有几种方法可以告诉 Team Build 运行测试你的构建。

  1. 单元测试可以从正在构建的解决方案中定义的测试列表运行。 该列表由构建定义引用,并执行所选列表中的所有测试。 更多信息此处
  2. 也可以通过定义通配符掩码来执行通配符测试(即 Test*.dll),指示 Team Build 运行与掩码匹配的程序集中存在的任何测试。 这也是在定义构建定义时完成的。

注意事项

如果您打算使用通配符方法并希望为测试配置启用代码覆盖率,则必须将以下内容添加到构建定义文件中以启用它。

<RunConfigFile>$(SolutionRoot)\TestRunConfig.testrunconfig</RunConfigFile>

请参阅我之前的问题以获取更多信息此处

it depends on which version of TFS you are running, so I will assume it is 2008.

Firstly, you must have Team Edition for Testers installed on the computer that will act as your build agent, as stated in How To: Create a Build Definition

There are a couple of ways to tell Team Build to run tests for your build.

  1. Unit tests can be run from a defined Test List within the Solution being built. This list is referenced by the build definition and all tests within the chosen list(s) are executed. More info here
  2. WildCard test exectution is also available by defining a wildcard mask (i.e. Test*.dll) that instructs Team Build to run any tests present in assemblies that match the mask. This is done when defining the build definition as well.

Things to note:

If you intend to use the wildcard method and want to enable code coverage for your test configuration, you must add the following to your build definition file to enable it.

<RunConfigFile>$(SolutionRoot)\TestRunConfig.testrunconfig</RunConfigFile>

See my previous question on this for more info here

忆梦 2024-07-16 01:04:49

如果您不想使用测试配置(管理起来很麻烦),只需将其添加到构建配置中即可在 .dll 中运行所有测试:

<ItemGroup>
    <TestContainerInOutput Include="MyProject.UnitTests.dll" />
</ItemGroup>

整个过程非常顺利且相当简单。 您可以通过在本地打开测试结果文件来检查构建服务器上的单元测试(有点痛苦),但通常您只需在本地运行单元测试,就可以立即看到结果。

如果您习惯使用 NUnit,您可以选择按类名对测试进行排序,它提供了类似的视图。

小心代码覆盖率,它会在编译时生成二进制文件的完整副本。 如果您的二进制文件足够大并且经常编译,它将很快耗尽驱动器空间。

If you don't want to use test configs (A Pain in the ass to manage) just run all the test in a .dll by adding this to the build config:

<ItemGroup>
    <TestContainerInOutput Include="MyProject.UnitTests.dll" />
</ItemGroup>

The whole process is smooth and fairly simple. You can inspect the unit tests that filaed on the build server by opening the test result file locally (a bit of a pain) but generally you'll just run the unit tests locally and you can see the results immediately.

If you are used to NUnit, you may opt to sort the tests by classname, it gives a similar view.

Careful with code coverage, it makes complete copies of your binaries on compile. If your binaries are sufficiently large and you compile often, it will eat through drive space quickly.

青衫负雪 2024-07-16 01:04:49

http://msdn.microsoft.com/en -us/library/cc981972(v=vs.90).aspx

我喜欢这个定义,因为它为您提供了完整的“演练”
创建项目
创建单元测试项目
配置团队构建以使用它单元测试

http://msdn.microsoft.com/en-us/library/cc981972(v=vs.90).aspx

I like this defination as it gives you a complete 'walkthrough' from
Creating the Project
Creating the Unit Test Project
To configuring Team build to use it Unit Test

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