Code Monkey home page Code Monkey logo

go-unit-test's Introduction

how to run unit test in GO

go unit testing

# run a unit test commonly
$ go test

# run a complete unit test (with verbose command flag) ==> by default
$ go test -v

# run a complete and specific unit test (with verbose command flag)
$ go test -v -run=TestYourFuncName

# run all complete unit test "from top module" folder with all their module or package
$ go test -v ./...

# run specified of Sub test on a module or package ==> better for Sub Test testing
$ go test -run=TestYourSubTestFuncName/SubTestName

# runs all the sub tests in the module or package with the named sub test `/SubTestName`
$ go test -run=/SubTestName

disclaimer We must entire the directory if will be testing for specified package, expect run all testing in top of folder command sh

go benchmark testing

# run all complete benchmark in specified module or package
$ go test -v -bench=.

# run all complete benchmark without unit test in specified module or package
$ go test -v -run=NotMatchUnitTest -bench=.

# run all complete Benchmark unit test "from top module" folder with all their module or package without unit test
$ go test -v -run=NotMatchUnitTest -bench=. ./...

# run all complete Benchmark unit test and unit test "from top module" folder with all their module or package
$ go test -v -bench=. ./...

# run a specified complete benchmark func without unit test in specified module or package
$ go test -v -run=NotMatchUnitTest -bench=BenchmarkUnitTestName

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.