Enable HTTPBuilder Debug Message

在用 groovy & cucumber 寫 API test 時,如果發生問題只會噴個 error 的 body 而已,這樣非常難 debug 。

而且有一些參數是設在 http header 上,如果把每個 API 的 header 都印出來,要到處塞 debug logger。如果是 https 的話,也沒辦法使用 tcpdump 來看。 這時可以用下列方法簡單的把 logger 設定打開,就可以直接噴在營幕上了,這樣比較好 debug。

$ mvn -B integration-test -Dcucumber.options="--tags @test_only" \ -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog \ -Dorg.apache.commons.logging.simplelog.showdatetime=true \ -Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG 

還有其他的參數可以參考後附的文章內容。

reference