如何创建启动和清理脚本的Visual Studio的测试项目? [英] How to create Startup and Cleanup script for Visual Studio Test Project?
问题描述
我使用Visual Studio的测试项目,正在修改与部署文件等测试配置(通过VS GUI),现在我需要编写一个启动脚本测试运行。
I'm using a Visual Studio Test project, am modifying the test config with deployment files, etc. (through the VS GUI) and now I need to write a Startup script for the test run.
我不知道用什么语言或文件类型或机制用于这些脚本。需要小费。
I have no clue what language or file type or mechanism is used for these scripts. Need a tip.
推荐答案
创建您的测试项目中的单元测试。在单元测试类中,创建 [TestInitialize]
和 [TestCleanup]
属性的方法。他们将每个测试方法之后之前运行/
Create a unit test in your test project. In the unit test class, create methods with the [TestInitialize]
and [TestCleanup]
attributes. They will be run before/after each test method.
或者,如果你想在类的所有试验后,之前运行/,创建静态方法 [ClassInitialize]
和 [ClassCleanup]
属性。
Or, if you want to run before/after all test in that class, create static methods with [ClassInitialize]
and [ClassCleanup]
attributes.
最后,为了运行前/装配中的所有测试之后,创建 [AssemblyInitialize]
和 [AssemblyCleanup] $ C静态方法$ C>属性。
Lastly, to run before/after all tests in the assembly, create static methods with [AssemblyInitialize]
and [AssemblyCleanup]
attributes.
这篇关于如何创建启动和清理脚本的Visual Studio的测试项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!