是什么`DeploymentItem`属性是什么意思?

编程入门 行业动态 更新时间:2024-10-18 06:08:28
本文介绍了是什么`DeploymentItem`属性是什么意思?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

让我们说我们有一个简短的程序:

Let's say we have a short program:

namespace ConsoleTryIt { static class Program { static void Main(string[] args) { var sum = Add(1, 2); } private static int Add(int p, int p2) { return p + p2; } } }

在创建这个类的单元测试类,Visual Studio中创建一个属性上的测试方法 DeploymentItem 。我看了MSDN这个属性,但仍然没有得到这意味着什么。

When create the unit test class for this class, Visual Studio create a test method with the attribute DeploymentItem. I read MSDN about this attribute but still don't get what it means.

/// <summary> ///A test for Add ///</summary> [TestMethod()] [DeploymentItem("ConsoleTryIt.exe")] public void AddTest() { var expected = 122; var actual = Program_Accessor.Add(1, 121); Assert.AreEqual(expected, actual); }

如果你的想法,请分享!

If you get the idea, please share!

谢谢大家对你的答案。这样的想法是要复制的参数,测试环境现状的文件夹中给出的项目。我的下一个问题是:为什么这个方法需要这个属性,有些却没有结果?我想这是涉及到对被测试类,但没有明确的对我的私有成员。

Thanks everyone for your answers. So the idea is to copy the item given in the argument to the testing evironment's folder. My next question is: why does this method need this attribute while others don't? I guess it's related to the private members on the tested class but nothing clear to me.

请继续讨论。

推荐答案

本规定由特定的测试所需的文件。测试系统创建其中测试是从运行新的目录。有了这个特性,可以使测试系统特定的文件复制到新目录中。

This specifies files that are required by the specific test. The test system creates a new directory where the tests are run from. With this attribute, you can make the test system copy specific files to that new directory.

更多推荐

是什么`DeploymentItem`属性是什么意思?

本文发布于:2023-11-02 14:10:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552619.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:属性   DeploymentItem

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!