• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    軟件單元測試實踐(VB版)

    發布: 2009-3-31 10:26 | 作者: 不詳 | 來源: 測試時代采編 | 查看: 79次 | 進入軟件測試論壇討論

    領測軟件測試網 vb有多個單元測試的軟件,如VBunit,communit。此處選擇communit來作為單元測試的,原因是一、它是完全開放源碼的,二、它不僅能測試VB源代碼,還能測試標準COM組件。communit可以從sourceforge.net下載,也可以本地下載,本地版本與有兩個修改,一是修正模板的安裝,原來的包沒有完全設置好,二是增加了時間的計算,能顯示測試花費的時間。

        使用,把包下載,然后解到一個目錄,運行install.exe,打開VB?梢园l現可以新建CoMunit Test Project的工程。有兩個文件frmTestRunner的form,TCTestContainer是測試類。下面我們看一下如何使用comunit。先下載測試代碼。

         這個代碼是測試二進制文件在數據庫里的存取。有關二進制代碼在數據庫里存取的技術問題,請看另一篇文章。用什么辦法來確定代碼是正確工作了呢?答案當然是單元測試。

        測試代碼很簡單,但的確很有效,它保證這段代碼是正確的工作了。

    ' COMUnit 1.1 - TestContainer Class

    Option Explicit

    ' Interface declaration
    Implements ITestContainer
    '定義一個recordset
    Dim k As New adodb.Recordset
    '定義bin類
    Dim BinTest As clsManagerBinFields
    '定義源文件名和目標文件名
    Dim SourceFile As String, DesFile As String
    ' 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
     ITestContainer_TestCaseNames = Array("TestFields")
    End Property

    ' Run the specified test case methods in this test container
    Public Sub ITestContainer_RunTestCase(oTestCase As ITestCase, oTestResult As TestResult)
    On Error GoTo ErrorHandler
     InvokeHook Me, oTestCase.Name, INVOKE_FUNC, oTestResult
    ' CallByName Me, oTestCase.Name, VbMethod, oTestResult
    Exit Sub
     ErrorHandler:
     oTestResult.AddError Err.Number, Err.Source, Err.Description
    End Sub

    'Initialize the test fixture
    '在測試開始時自動調用
    Public Sub ITestContainer_Setup()

    ' TODO: initialize your test fixture here
    '指定源文件名,這里就指定這個文件
    SourceFile = App.Path & "\tctestcontainer.cls"
    '指定目標文件名,這里指定為當前目錄下的test
     DesFile = App.Path & "\test"

     

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    TAG: 單元 軟件 實踐

    31/3123>

    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備2023014753號-2
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>