VB6-单元测试工具ComUnit

发表于:2014-6-24 11:03

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:songfun    来源:51Testing软件测试网博客

  在使用过NUnit后,一直想在VB6中使用一下单元测试工具,目前比较流行的是VBUnit和ComUnit,我比较喜欢ComUnit主要是它是开源的,当然用起来比较爽了,可以在http://comunit.sourceforge.net/进行下载。
  ComUnit使用比较简单,注意下边几点后就可以使用了。
' COMUnit 1.1 - TestRunner form
Option Explicit
' Initialize the TestRunner control
Private Sub Form_Load()
' TODO: add instances of your TestContainer classes to the UnitRunner control
' e.g. UnitRunner1.AddTestContainer New TCTestContainer
'************************************************
'必须向UnitRunner添加一个控制对象,别的不需要修改
UnitRunner1.AddTestContainer New TCTestContainer
'************************************************
End Sub
' Run the tests selected in the UnitRunner
Private Sub btnRun_Click()
UnitRunner1.Run
End Sub
' Close the form
Private Sub btnClose_Click()
Unload Me
End Sub
' Resize the UnitRunner control and the buttons on the form
Private Sub Form_Resize()
UnitRunner1.Move 0, 0, ScaleWidth, PosInt(ScaleHeight - btnClose.Height - 50)
btnClose.Move PosInt(ScaleWidth - btnClose.Width), PosInt(ScaleHeight - btnClose.Height)
btnRun.Move PosInt(ScaleWidth - btnClose.Width - btnRun.Width - 100), PosInt(ScaleHeight - btnRun.Height)
End Sub
Private Function PosInt(iValue) As Integer
PosInt = IIf(iValue > 0, iValue, 0)
End Function
' COMUnit 1.1 - TestContainer Class
'建议类的前缀为TC
Option Explicit
' Interface declaration
Implements ITestContainer
' Fixture Member Variables
' TODO: specify your TestContainer test fixture member variables here
' Return the name of the different test case methods in this test container
Public Property Get ITestContainer_TestCaseNames() As Variant()
' TODO: add the names of your test methods as a parameter into the Array() function
21/212>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号