要运行我的程序,我必须给它一些参数:./main list
或./main serve --config=.env.test
。
我必须为此编写集成测试。为了查看测试覆盖率,我在Goland IDE中单击“带覆盖率运行”按钮。
当我单击“ Run with Coverage”时,我看到Goland执行以下命令:
/usr/lib/go/bin/go test -c -coverpkg=./... -covermode=atomic -i -test.run=TestMain -o /tmp/___coverage_test main #gosetup
/usr/lib/go/bin/go tool test2json -t /tmp/___coverage_test -test.v -test.coverprofile /home/admin/.GoLand2019.3/system/coverage/main$coverage_test.out serve --config=.env.test #gosetup
这给我一个错误:Error: unknown command "/home/admin/.GoLand2019.3/system/coverage/main$coverage_test.out" for "app"
。
但是,如果我手动运行:
/usr/lib/go/bin/go tool test2json -t /tmp/___coverage_test -test.v -test.coverprofile=/home/admin/.GoLand2019.3/system/coverage/main$coverage_test.out serve --config=.env.test #gosetup
它工作正常。
我该怎么说Goland使用-test.coverprofile=[path]
而不是-test.coverprofile [path]
。我在这里需要=
。