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

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

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

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

    淺談對單元測試對象的認識

    發布: 2009-4-07 09:02 | 作者: 不詳 | 來源: 測試時代采編 | 查看: 60次 | 進入軟件測試論壇討論

    領測軟件測試網

    接下來是《Testing Objected-Oriented Systems, Models, Patterns, and tools》(《面向對象系統測試 模型,視圖與工具》)這本大部頭的書,我手中的是清華大學出版社出版的影印本,其中沒有直接的對單元測試的定義,但在描述class scope testing時,有如下描述(P350):


            “Class scope testing corresponds with the classical definition of unit testing: exercising a relatively small software component, usually via a driver, in isolation.”


            我認為這段話也清楚地表明了作者認為針對類的測試是屬于單元測試的立場。

            當然,還有一些書中的對單元測試的描述我也進行了引用,例如,在《The art of Software Testing (2nd)》一書中,單元測試被描述為:


            “Module testing (or unit testing) is a process of testing the individual subprograms, subroutines, or procedures in a program. That is, rather than initially testing the program as a whole, testing is first focused on the smaller building blocks of the program.”


    在《Pragmatic Unit Testing in C Sharp with NUnit》書中,單元測試描述如下:


            “A unit test is a piece of code written by a developer that exercises a very small, specific area of functionality of the code being tested. Usually a unit test exercises some particular method in a particular context. For example, you might add a large value to a sorted list, then confirm that this value appears at the end of the list. Or you might delete a pattern of characters from a string and then confirm that they are gone.
        Unit tests are performed to prove that a piece of code does what the developer thinks it should do.”


            總之,從以上的內容來看,似乎沒有任何一本書直接支持《軟件測試方法和技術》中提到的這個觀點。

            對于單元測試,我的觀點是:

            單元測試是針對“單元”的測試,這是毫無疑問的。但何謂“單元”,則并沒有特別明確的區分,在不同的上下文語境中,單元可以是不同的含義。在RUP中,單元測試的對象可以是文件、DLL或是類等等。 
            從《Systematic Software Testing》提供的單元測試模板來看,在確定單元測試范圍的時候,單元測試范圍的內容可以是“Unit/Module/Component”,可見,在作者看來, 單元測試的范圍可以是Unit(代碼片斷)、Module(模組)或者是Component(構件)。 
            從目前的TDD和單元測試的發展趨勢來看,在使用面向對象方法開發的系統中,越來越多的人傾向于將單元測試理解為針對類的測試,或是針對幾個緊密聯系的類的測試,并不需要被測單元具有UI層面上的含義(例如,一個純粹的算法類)。 
            在實際的工作中,具體“單元”的選取應該是根據具體的情況來確定的,沒有一個非常統一的標準。例如,如果該系統大量使用外部的組件(component),單元測試的內容更多的是以組件來進行,但如果系統開發中要求對每個類進行測試,類就應該是單元測試的最好關注單位。

    延伸閱讀

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

    22/2<12

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