running a test suite as part of main application

agolangf · · 365 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi</p> <p>I&#39;m looking to create an application that runs a test suite as it&#39;s primary function - something like this:</p> <pre><code>package main import ( &#34;testing&#34; &#34;github.com/stretchr/testify/assert&#34; &#34;github.com/stretchr/testify/suite&#34; ) var t *testing.T func main() { t = &amp;testing.T{} suite.Run(t, new(ExampleTestSuite)) } type ExampleTestSuite struct { suite.Suite VariableThatShouldStartAtFive int } func (suite *ExampleTestSuite) TestExample() { assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive) } </code></pre> <p>That I can later tweak to output junit reports.</p> <p>The above compiles, and raises no errors - but also doesn&#39;t execute the tests.</p> <p>There are a bunch of exported methods in the testing package, but they all suggest that they&#39;re only exported for other internal packages to consume, and that I probably shouldn&#39;t be playing there.</p> <p>Anyone else done something similar, or have any suggestions as to how I might proceed?</p> <p>Thanks in advance!</p>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

365 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传