• golang-test-tool-gotests


    gotests介绍

    gotests是一个Golang命令行工具 ,让Go测试变得容易。它根据目标源文件的函数和方法签名生成表驱动的测试(TDD)。任何测试文件中新的依赖都会被自动倒入

    Demo

    下面是gotests在使用Sublime Text 3插件时的情况。此外他还支持Emacs、Emacs、Vim、Atom Editor、Visual Studio Code和IntelliJ Goland。

    Installation

    Go最小版本 : Go 1.6

    Use go get to install and update:

    $ go get -u github.com/cweill/gotests/...

    命令行可选参数如下:

      -all           为所有函数和方法生成go测试用例
    
      -excl          支持正则,为未匹配的函数和方法生成测试用例。优先级高于-only、-export和-all
    
      -exported      为导出的函数和方法生成GO测试。优先级高于 -all 和-only
    
      -i             在错误消息中打印测试输入
    
      -only          支持正则,只对匹配的函数生效,优先级高于 -all
    
      -w             将输出信息写入文件而非直接输出
    
      -nosubtests    关闭自动生成功能,仅对Go 1.7+有效
    
      -template_dir  可选参数,指定测试代码保存目录

    使用demo(自动生成go测试用例):
    gotests -all -w  xxx.go

     goland-generate-test-cases-for-file ; 

    1, point current go file ,right menu ,select Generate ... 

    2,select "Tests for fiile ", 

    then it helped generate  main case for file ; 

     

  • 相关阅读:
    TP框架的小知识
    执行sql语句的注意事项
    关于引用值的总结
    几道经典容易错的php面试题
    Smarty模板的学习_2
    Smarty模板的学习_1
    数据库的权限操作
    redhat与zlib兼容性问题?
    Ubuntu中Qt Creator无法启动调试
    ubuntu下安装chrome浏览器和flash插件
  • 原文地址:https://www.cnblogs.com/lavin/p/10062375.html
Copyright © 2020-2023  润新知