軟件測試(software testing)細碎知識

目錄

 

一、Basic knowledge and Unit Testing

二、Integration testing

三、System testing


一、Basic knowledge and Unit Testing

1. In unit testing. Why do we use the term System Under Test? Aren’t we testing Units? 

    在xUnit Test Patterns的官方文檔中可以找到以下說明: "system under test". It is short for "whatever thing we are testing" and is always defined from the perspective of the test. When we are writing unit tests the system under test (SUT) is whatever class (a.k.a. CUT), object (a.k.a. OUT) or method(s) (a.k.a. MUT) we are testing; when we are writing customer tests, the SUT is probably the entire application (a.k.a. AUT) or at least a major subsystem of it. The parts of the application that we are notverifying in this particular test may still be involved as a depended-on component (DOC).

2. Weak-Strong和Normal-Robust關係的理解?

    https://blog.csdn.net/weixin_42569673/article/details/103427650

3. How many assertions in a test method? Is it OK to put multiple assert statements in one test statement? 

    It depends. If a test runs the exercise phase and then needs to check several items about the SUT, then it is OK to use several assert statements.

    Is a method trying to test too many things? e.g. one test checks if setup is successful and then checks if sending emails is successful. If it is, then avoid doing this – split into separate methods.

4. Access to Private Methods?

    Tools like JUnit are designed to access the public interface  In a good design, the protected and private methods are there to support the operations of the public interface Testing the public interface should also exercise the protected/private elements. 

    If you really need to test a protected and private method directly, there are tools that can be used to get access to the private method For protected, you can subclass the SUT and call the protected methods For the private methods, you can use some tricks to change the access modifier.

5. Test doubles and test driver module.

    Test Double: is used to simulate the modules that the SUT will interact with. These are typically used to process limited situations (‘pre-set data’)

     Test driver module: is used to exercise the SUT. It either receives data or loads tests. It runs those tests and collects the results. The results are then available for analysis.

                       

6. 4 kind of test doubles

Dummy: An object that is passed around but never used. Typically used to fulfill the parameter list of a method.

Stub: An object that always returns the same canned response. May also hold some dummy state.

Fake: An actual working implementation (not of production quality or configuration) that can replace the real implementation.

Mock: An object that represents a series of expectations and provides canned responses.

二、Integration testing

1. 需求活動與測試環節的對應,V-model。

                          

2. 集成方法

    Big bang: 將全部module鏈接在一起成一個system。可限制test doubles和drivers的個數,但很難辨別並隔離出錯誤所在處,同時沒有驗證mudule邊界的interface。

    Top-Down: 包含深度優先和廣度優先。

    Bottom-Up:  從底層依賴少的部分開始實現,然後順着鏈接向上,通過driver來驗證。相比Top-Down使用較少的test doubles。

    Mixed approach: Top-down和Bottom-up混合使用

三、System testing

1. Why system testing?

    Some properties only verifiable at system level

         Installation , usability, compatibility, etc.

    We may involve users at this level:

        Use cases may not map to any specific integration unit,

        Use of alpha and beta tests

    The environment of the system is taken into account

發佈了17 篇原創文章 · 獲贊 16 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章