首页 > 其他 > 详细

gocheck框架

时间:2019-12-23 17:17:58      阅读:92      评论:0      收藏:0      [点我收藏+]

1.  引用包 :  gocheck "gopkg.in/check.v1"

2. 自动化测试入口   :Test_run(t *testing.T)

3. 将自定义的测试用例集,注册到如下suites集合中即可

代码如下:

 1 import (
 2     "testing"
 3     gocheck "gopkg.in/check.v1"
 4 )
 5 
 6 var AllSuites []interface{}
 7 
 8 
 9 func RunSuites(suites []interface{}, t *testing.T) {
10     for _, suite := range suites {
11         var _ = gocheck.Suite(suite)
12         AllSuites = append(AllSuites, suite)
13     }
14     gocheck.TestingT(t)
15 }
16 
17 
18 
19 var suites = []interface{}{
20     //add test suite
21      &domain_transfer{},
22 }
23 
24 func Test_run(t *testing.T)  {
25     RunSuites(suites, t)
26 }

测试用例代码如下:

 1 import (
 2     . "gopkg.in/check.v1"
 3 )
 4 
 5 type domain_transfer struct {
 6 }
 7 
 8 func (s *domain_transfer) SetUpSuite(c *C) {
 9   
10    print("do some preparation here")
11     :::
12      
13 }
14 
15 func (s *domain_transfer) TearDownSuite(c *C) {
16      :::
17 }
18 
19 func (s *domain_transfer) TestDomainTest(c *C,) {
20     :::
21     assert.Equal(c,true,result)
22 
23 }

gocheck框架

原文:https://www.cnblogs.com/dapingguo/p/12084371.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!