How to test the main package functions in golang?

后端 未结 4 1822
情书的邮戳
情书的邮戳 2021-01-03 17:43

I want to test a few functions that are included in my main package, but my tests don\'t appear to be able to access those functions.

My sample main.go file looks li

4条回答
  •  庸人自扰
    2021-01-03 18:01

    Unit tests only go so far. At some point you have to actually run the program. Then you test that it works with real input, from real sources, producing real output to real destinations. For real.

    If you want to unit test a thing move it out of main().

提交回复
热议问题