/go-gen-test

Generate tests for go code from emacs

Primary LanguageEmacs LispGNU General Public License v3.0GPL-3.0

go-gen-test

License GPL 3 MELPA

go-gen-test is package for generating tests for go code from emacs. It is simple wrapper around gotests.

asciicast

Usage

Commands

go-gen-test-dwim

Generate tests for functions you want to. If you call this function while region is active it extracts functions defined in this region and generate tests for it. Else it generates tests for exported or all functions. You can customize this behavior with go-gen-test-default-functions.

go-gen-test-all

Generate tests for all functions.

go-gen-test-exported

Generate tests for all exported functions.

Customization

M-x customize-group Enter go-gen-test Enter

Setup

You can now install package go-gen-test from MELPA. Just M-x package-installEnter go-gen-test Enter.

Also you should install gotests:

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

Then you can bind needed commands to preffered keys:

(defun my-go-gen-test-setup ()
  "My keybindings for generating go tests."
  (interactive)
  (local-set-key (kbd "C-c C-g") #'go-gen-test-dwim))

(add-hook 'go-mode-hook #'my-go-gen-test-setup)