自動化測試===自動化測試分類(一)


分層的自動化測試

測試金字塔的概念由敏捷大師Mike Cohn 在他的《Succeeding with Agile》一書中首次提出,如圖7.1所示。他的基本觀點是:我們應該有更多的低級別的單元測試,而不僅僅是通過用戶界面運行高層的端到端的測試。

 Martin Fowler 大師在測試金字塔模型的基礎上提出分層自動化測試的概念。在自動化測試之前加了一個“分層”的修飾,用來區別於“傳統的”自動化測試。那么什么是傳統的自動化測試?為何要提倡分層自動化測試的思想呢?

所謂傳統的自動化測試我們可以理解為基於產品UI 層的自動化測試,它是將黑盒功能測試轉化為由程序或工具執行的一種自動化測試。

在目前的大多數研發組織當中,都存在開發與測試團隊割裂(部門牆)、質量職責錯配(測試主要對質量負責)的問題,在這種狀態下,測試團隊的一個“正常”反應就是試圖在測試團隊能夠掌控的黑盒測試環節進行盡可能全面的覆蓋,甚至是盡可能全面的UI 自動化測試。

這可能會導致兩個惡果:一是測試團隊規模的急劇膨脹;二是所謂的全面UI 自動化測試運動。因為UI是非常易變的,所以UI 自動化測試維護成本相對高昂。

 

單元測試與模塊測試

 單元測試(Unit testing)
In computer programming, unit testing is a software testing method by which individual units of source code, sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures, are tested to determine whether they are fit for use.
Intuitively, one can view a unit as the smallest testable part of an application. In procedural programming, a unit could be an entire module, but it is more commonly an individual function or procedure.In object-oriented programming, a unit is often an entire interface, such as a class, but could be an individual method. Unit tests are short code fragments created by programmers or occasionally by white box testers during the development process. It forms the basis for component testing。

總結一下就是:

 1、單元測試是應用程序的最小可測試部分。
2、在面向過程編程中,單元也可以是整個模塊,但常見的是單個函數或過程。
3、在面向對象編程中,單元通常是整個接口,例如類,但可以是單獨的方法。
4、單元測試多數情況下是由程序員自己完成的。

 

模塊測試(Module testing)
大多時候,我們認為單元測試與模塊測試是一樣的。我在國外某網站找到另段關於模塊測試的定義。
A library may be composed of a single compiled object or several compiled objects. There is only a slightdifference between unit testing and module testing. Modules are fully formed chunks of coherent source code that can typically be tested by driving a few function signatures with various stimuli. On the other hand, unit testing (which is considered as part of the implementation phase for this software development process) may involve testing one small part of a function that will never formally implement any function interface.

我們讀到了幾個模塊測試的解釋:
1、首先,這段定義認為模塊測試與單元測試有細微的區別。
2、模塊測試是針對具有明顯的功能特征的代碼塊進行的測試。
3、並且,它認為單元測試可能只涉及測試一小部分的功能。
4、模塊測試多數情況下由其它程序員或測試人員進行。

接口測試

我根據自己的理解和認識大致把接口分為兩類:程序接口和協議接口。

關於程序接口,也可以看作是程序模塊接口,具體到程序中一般就是提供了輸入輸出的類、方法或函數。對於程序接口的測試,一般需要使用與開發程序接口相同的編程語言,通過不同的傳入不同的參數,來驗證程序接口的功能。


關於協議接口,一般指系統通過不同的協議來提供的接口,例如HTTP/SOAP 協議等。這種類型接口對底層代碼做了封裝,通過協議的方式對外提供調用。因為不涉及到程序層面,所以,不受編程語言的限制;我們可以通過其它編程語言或工具對其進行測試。

 

順便提一下


 

如果你也喜歡Python 這里有一群Python愛好者匯集在此。

關注微信公眾號:【軟件測試技術】,回復 888,獲取QQ群號。 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM