<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] <br> ### 一般項目結構 * Collection 項目(測試集) * Folder 模塊 * request1 請求1 * request2 請求2 ### Collection 介紹 我們可以稱之為‘測試骨架’或‘測試集’。從工具外觀上,像是一個文件夾,`用于組織和管理接口用例`相關信息。實際上它是一個可執行文件,是所有API和Postman內置工具的核心。是所有內置工具的`執行的開始`,包括:MOCK、文檔、測試、監測、發布。 ![](https://box.kancloud.cn/402d0a51ae5cb5c7d942bde79588177e_539x413.jpg) ### 創建 Collection ![](https://box.kancloud.cn/ace0696f0c182ee44755b4051a85ebd2_402x269.jpg) ![](https://box.kancloud.cn/b44c98dde9260766bc09898f36f3d2e5_798x692.jpg) - 測試集名稱:一般可以采用項目名稱 - 描述文檔:描述項目的信息 - 前置腳本:在這個測試集下的每個接口,請求發送之前執行的腳本,一般用于參數構造處理 - 斷言測試:在這個測試集下的每個接口響應后,都會執行的斷言 - 變量設置:在這個測試集下的所有接口請求,都可以共享的變量 ### 分享 Collection 當我們需要與其他團隊成員分享Collection時,我們有多鐘分享的形式,下面只介紹幾種常見的。 - 通過分享URL,使其他成員可以通過URL能訪問到Collection ![](https://box.kancloud.cn/78afa00c1ec6d341a2047243b0a8fad7_420x293.jpg) ![](https://box.kancloud.cn/8efd6564662f6376d2e5e139d4f5a144_518x206.jpg) - 通過注冊賬號,共享項目 - 通過導出Collection文件,實現傳播 ![](https://box.kancloud.cn/5a6e7ecb0daf705ae8a8fe9074be83b3_431x312.jpg) ![](https://box.kancloud.cn/a90f22a6ca8fc296313f75af36a5fa19_482x309.jpg) 這里導出到`D://tmp.postman_collection.json`,下面命令行執行會用到。 ### 運行 Collection 當我們運行一個Collection后,在Colection中的requests會逐一順序執行,這在我們做API自動化測試中,起著非常好的作用。 #### 通過app中的“Runner”按鈕運行 ![](https://box.kancloud.cn/1ea575156bca3df6a174bd2e8d5cab37_555x78.jpg) ![](https://box.kancloud.cn/c59626798ea2be3f57a84d0a7bff5736_501x793.jpg) 運行結果報告如下: ![](https://box.kancloud.cn/08a558b6c20f25b3eadc4043db87bd97_1267x346.jpg) #### 通過 `Newman` 命令行工具運行 Newman 是一個Collection Runner命令行工具,它是建立在Node.js上的,運行Newman之前,需確保我們已經安裝了Node.js 安裝后Node.js后,通過npm進行Newman安裝 ```cmd npm install -g newman ``` **通過Collection 文件運行**,命令行運行命令如 ```cmd $ newman run D://tmp.postman_collection.json ``` 運行結果如下: ```cmd newman tmp → postman-echo.com/post POST postman-echo.com/post [200 OK, 642B, 739ms] → postman-echo.com/get?foo1=bar1&foo2=bar2 GET postman-echo.com/get?foo1=bar1&foo2=bar2 [200 OK, 539B, 238ms] ┌─────────────────────────┬──────────┬──────────┐ │ │ executed │ failed │ ├─────────────────────────┼──────────┼──────────┤ │ iterations │ 1 │ 0 │ ├─────────────────────────┼──────────┼──────────┤ │ requests │ 2 │ 0 │ ├─────────────────────────┼──────────┼──────────┤ │ test-scripts │ 0 │ 0 │ ├─────────────────────────┼──────────┼──────────┤ │ prerequest-scripts │ 0 │ 0 │ ├─────────────────────────┼──────────┼──────────┤ │ assertions │ 0 │ 0 │ ├─────────────────────────┴──────────┴──────────┤ │ total run duration: 1049ms │ ├───────────────────────────────────────────────┤ │ total data received: 553B (approx) │ ├───────────────────────────────────────────────┤ │ average response time: 488ms │ └───────────────────────────────────────────────┘ ``` **通過Collection分享URL運行**,格式如: ```cmd $ newman run https://www.getpostman.com/collections/cb208e7e64056f5294e5 ``` **更多newman參數** ```cmd $ newman run -h ``` 參數如下: ```cmd Options: Utility: -h, --help output usage information -v, --version output the version number Basic setup: --folder [folderName] Specify a single folder to run from a collection. -e, --environment [file|URL] Specify a Postman environment as a JSON [file] -d, --data [file] Specify a data file to use either json or csv -g, --globals [file] Specify a Postman globals file as JSON [file] -n, --iteration-count [number] Define the number of iterations to run Request options: --delay-request [number] Specify a delay (in ms) between requests [number] --timeout-request [number] Specify a request timeout (in ms) for a request Misc.: --bail Stops the runner when a test case fails --silent Disable terminal output --no-color Disable colored output -k, --insecure Disable strict ssl -x, --suppress-exit-code Continue running tests even after a failure, but exit with code=0 --ignore-redirects Disable automatic following of 3XX responses ``` <hr style="margin-top:100px"> :-: ![](https://box.kancloud.cn/331f659e8e6cddb0d9f182e00e32803f_258x258.jpg) ***微信掃一掃,關注“python測試開發圈”,獲取更多測試開發分享!***
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看