在使用覆蓋信息中測試OS.EXIT方案(coveralls.io/goveralls)
提出了修改的測試方法。 Rather than reinvoking the binary, testing is performed by modifying the os.Exit() or log.Fatalf() function to capture exit codes or error logs.
Modified foo/bar.go:
package foo 進口 ( “ FMT” “ OS” ) var osexit = os.exit func crasher(){ fmt.println(“火焰下來!”) osexit(1) }
此方法允許覆蓋工具準確跟踪OS.exit()的執行,並確保在測試結果中介紹例程退出的測試用例。在維護準確的覆蓋範圍報告的同時,測試OS.EXIT()方案。免責聲明: 提供的所有資源部分來自互聯網,如果有侵犯您的版權或其他權益,請說明詳細緣由並提供版權或權益證明然後發到郵箱:[email protected] 我們會在第一時間內為您處理。
Copyright© 2022 湘ICP备2022001581号-3