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

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] # 單測 | 類型 | 格式 | 作用 | | --- | --- | --- | | 測試函數 | 函數名前綴為Test | 測試程序的一些邏輯行為是否正確 | | 基準函數 | 函數名前綴為Benchmark | 測試函數的性能 | 命令: go test 在包目錄內,所有以`_test.go`為后綴名的源代碼文件都是`go test`測試的一部分,不會被`go build`編譯到最終的可執行文件中。 `go test`命令會遍歷所有的`*_test.go`文件中符合上述命名規則的函數 ## 測試函數的格式 ~~~go func TestName(t *testing.T){ // ... } eg: func TestCalc(t *testing.T) { c := Calc(2, 3) n := 5 fmt.Println(c == n) } ~~~ >go test -v 可查看測試的函數名稱和測試時間 > go test -v -run="xxx" eg:go test -v -run="Su" 函數名稱:TestSub 它對應一個正則表達式,只有函數名匹配上的測試函數才會被`go test`命令執行。 > go test -conver 測試代碼覆蓋率 # 基準測試 ~~~go func BenchmarkName(b *testing.B){ // ... } func BenchmarkSub(b *testing.B) { c := Sub(5, 3) n := 2 fmt.Println(c == n) } ~~~ 命令: >go test -bench=Name eg:go test -bench=Sub ~~~bash go test -bench=. ~~~ 如果Name是“.”,代表運行文件所有的基準方法 > go test -bench=Name -benchmem 可獲得內存分配的統計數據
                  <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>

                              哎呀哎呀视频在线观看