<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                # 單元測試 單元測試(unit testing),是指對軟件中的最小可測試單元進行檢查和驗證。對于單元測試中單元的含義,一般來說,要根據實際情況去判定其具體含義,如C語言中單元指一個函數,Java里單元指一個類,圖形化的軟件中可以指一個窗口或一個菜單等。總的來說,單元就是人為規定的最小的被測功能模塊。單元測試是在軟件開發過程中要進行的最低級別的測試活動,軟件的獨立單元將在與程序的其他部分相隔離的情況下進行測試。 單元測試的書寫、驗證,互聯網公司幾乎都是研發自己完成的,我們要保證代碼出手時可交付、符合預期。如果連自己的預期都沒達到,后面所有的工作,都將是額外無用功。 Lua中我們沒有找到比較好的測試庫,參考了Golang、Python等語言的單元測試書寫方法以及調用規則,我們編寫了[lua-resty-test](https://github.com/membphis/lua-resty-test)測試庫,這里給自己的庫推廣一下,希望這東東也是你們的真愛。 > nginx示例配置 ~~~ #you do not need the following line if you are using #the ngx_openresty bundle: lua_package_path "/path/to/lua-resty-redis/lib/?.lua;;"; server { location /test { content_by_lua_file test_case_lua/unit/test_example.lua; } } ~~~ > test_case_lua/unit/test_example.lua: ~~~ local tb = require "resty.iresty_test" local test = tb.new({unit_name="bench_example"}) function tb:init( ) self:log("init complete") end function tb:test_00001( ) error("invalid input") end function tb:atest_00002() self:log("never be called") end function tb:test_00003( ) self:log("ok") end -- units test test:run() -- bench test(total_count, micro_count, parallels) test:bench_run(100000, 25, 20) ~~~ - init里面我們可以完成一些基礎、公共變量的初始化,例如特定的url等 - test_*****函數中添加我們的單元測試代碼 - 搞定測試代碼,它即是單元測試,也是成壓力測試 > 輸出日志: ~~~ TIME Name Log 0.000 [bench_example] unit test start 0.000 [bench_example] init complete 0.000 \_[test_00001] fail ...de/nginx/test_case_lua/unit/test_example.lua:9: invalid input 0.000 \_[test_00003] ↓ ok 0.000 \_[test_00003] PASS 0.000 [bench_example] unit test complete 0.000 [bench_example] !!!BENCH TEST START!! 0.484 [bench_example] succ count: 100001 QPS: 206613.65 0.484 [bench_example] fail count: 100001 QPS: 206613.65 0.484 [bench_example] loop count: 100000 QPS: 206611.58 0.484 [bench_example] !!!BENCH TEST ALL DONE!!! ~~~ 埋個伏筆:在壓力測試例子中,測試到的QPS大約21萬的,這是我本機一臺Mac Mini壓測的結果。構架好,姿勢正確,我們可以很輕松做出好產品。 后面會詳細說一下用這個工具進行壓力測試的獨到魅力,做出一個NB的網絡處理應用,這個測試庫應該是你的利器。
                  <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>

                              哎呀哎呀视频在线观看