我想创建一个单元测试的负载,以确保我的存储过程正常,但我失败了(我是新来测试视觉工作室)。Visual Studio中的单元测试
基本上我要做到以下几点:
<testclass()>
Dim myglobalvariable as integer
<testmethod()>
Public sub test()
-> use stored procedure to insert a record
set myglobalvariable = result from the sp
end sub
public sub test2()
-> use a stored procedure to modify the record we just added
end sub
public sub test3()
-> use a stored procedure to delete the record we just added
end sub
end class
的问题是,因为测试没有按顺序运行,测试2和3失败,因为全局变量未设置。
建议? :。'(
你应该瞄准编写测试不相互依赖。应该首先执行测试所需的任何设置/拆卸。另外,如果实际调用数据库,则这比集合测试更像是集成测试,因为您同时测试数据库和访问代码。 – forsvarir 2011-04-01 14:58:27