Vim snippets for easy Golang testing
16 Sep 2015If you are a regular reader of this blog or even follow my rants on Twitter
( @KensoDev ), you know I am an automation freak, if I do something more than a
couple of times a day, I will definitely automate it a.s.a.p.
Since I’ve started working with Go, one of the things I’ve been missing the
most is an automated way to start testing a file.
I am talking about the plumbinb, the initial package name, the Suite etc…
I created a couple of vim snippets for this that save me a lot of time and I
thought it’s worth sharing
snippet gotestclass
package ${1}
import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
. "gopkg.in/check.v1"
"testing"
)
func Test${2}(t *testing.T) { TestingT(t) }
type $2Suite struct{}
var _ = Suite(&$2Suite{})
func (s *$2Suite) Test${3}(c *C) {
}
snippet gotest
func (s *${1}Suite) Test${2}(t *testing.T) {
}
If you are interested in this sort of automation and shortcuts, you can also
check out my dotfiles on github kensodev/dotfiles Or my vim settings on kensodev/dotvim