Kar*_*ski 5 sql-server unit-testing visual-studio-2012 sql-server-data-tools
SQL Server单元测试中的“测试初始化”脚本在每种测试方法之前运行,而“测试清除”在每种测试方法之后运行。
所以例如我有这个结构
UnitTests -- Main Project
- FooSchema -- Test Class
- SprocFoo1 -- Individual Unit Tests / Test Methods
- SprocFoo2
- BarSchema
- SprocBar1
- SprocBar2
Run Code Online (Sandbox Code Playgroud)
像这样的测试运行
-- Test Initialiaze for TestClass FooSchema
-- Pre-Test -- for SprocFoo1
-- Test -- for SprocFoo1
-- Post-Test -- for SprocFoo1
-- Pre-Test -- for SprocFoo2
-- Test -- for SprocFoo2
-- Post-Test -- for SprocFoo2
-- Test Cleanup for TestClass FooSchema
-- Test Initialiaze for TestClass BarSchema
-- Pre-Test -- for SprocBar1
-- Test -- for SprocBar1
-- Post-Test -- for SprocBar1
-- Pre-Test -- for SprocBar2
-- Test -- for SprocBar2
-- Post-Test -- for SprocBar2
-- Test Cleanup for TestClass BarSchema
Run Code Online (Sandbox Code Playgroud)
如何添加一个在项目开始时就可以运行的脚本以及一个在项目开始时就可以运行的脚本?
所以它会像这样运行
-- Pre MasterUnitTest
-- Test Initialiaze for TestClass FooSchema
-- Pre-Test -- for SprocFoo1
-- Test -- for SprocFoo1
-- Post-Test -- for SprocFoo1
-- Pre-Test -- for SprocFoo2
-- Test -- for SprocFoo2
-- Post-Test -- for SprocFoo2
-- Test Cleanup for TestClass FooSchema
-- Test Initialiaze for TestClass BarSchema
-- Pre-Test -- for SprocBar1
-- Test -- for SprocBar1
-- Post-Test -- for SprocBar1
-- Pre-Test -- for SprocBar2
-- Test -- for SprocBar2
-- Post-Test -- for SprocBar2
-- Test Cleanup for TestClass BarSchema
-- Post MasterUnitTest
Run Code Online (Sandbox Code Playgroud)
如果不知道运行特殊主前/后测试的原因 - 您可以尝试实现它创建一个有序测试:
"您可以使用有序测试以特定顺序运行 SQL Server 单元测试。有关详细信息,请参阅如何:创建有序测试 (Visual Studio 2012)。 http://msdn.microsoft.com/library/ms182631 .aspx “
归档时间: |
|
查看次数: |
1365 次 |
最近记录: |