showing coverage of functional tests without blind spots

后端 未结 2 2002
清酒与你
清酒与你 2021-01-19 04:31

I have a production golang code and functional tests for it written not in golang. Functional tests run compiled binary. Very simplified version of my production code is her

2条回答
  •  礼貌的吻别
    2021-01-19 04:58

    In my pkglint project I have declared a package-visible variable:

    var exit = os.Exit
    

    In the code that sets up the test, I overwrite it with a test-specific function, and when tearing down a test, I reset it back to os.Exit.

    This is a simple and pragmatic solution that works well for me, for at least a year of extensive testing. I get 100% branch coverage because there is no branch involved at all.

提交回复
热议问题