gria

command module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2018 License: MIT Imports: 4 Imported by: 0

README

Gria

GoDoc CircleCI codecov Go Report Card GitHub last commit GitHub tag License

CLI tool for golang's test code scaffolding.

Overview

gria is CLI tool for golang's test code scaffolding. Parse packages with go/ast and generate test functions skeltons.

Getting Started

First, install gria.

Create a sample code foo.go.

package foo

func Foo() string {
	return "foo"
}

Then run gria.

$ gria .
create a test file: foo_test.go

Open the foo_test.go.

package foo

import (
	"testing"
)

func TestFoo(t *testing.T) {
}

Then add a struct and method.

package foo

func Foo() string {
	return "foo"
}

type User struct {
	name string
}

func (user User) GetName() string {
	return user.name
}

Then run gria again.

$ gria .
add a test skelton code to a test file: foo_test.go

Open the foo_test.go.

package foo

import (
	"testing"
)

func TestFoo(t *testing.T) {
}

func TestUserGetName(t *testing.T) {
}

Note the existing code is not overwritten.

Install

$ go get github.com/suzuki-shunsuke/gria

or Download a binary from the release page.

Check whether gria is installed.

$ gria -v
gria version 0.1.0

Usage

Show help.

$ gria --h
$ gria --help
$ gria h
$ gria help

Show version.

$ gria -v
$ gria --version

Generate tests.

$ gria <package_directory_path> [<package_directory_path> ...]

If you want to pass packages recursively, use go list.

$ go list -f "{{.Dir}}" ./... | xargs gria

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL