GoConvey Documentation

repository·master·Indexed 27 days ago

https://github.com/smartystreets/goconvey

GoConvey is a testing tool for Go that provides a BDD-style syntax and a real-time web UI to visualize test results and coverage. It integrates with the standard go test tool and allows users to define test scopes using the Convey function and assertions using the So function.

Tokens
1.3K
Snippets
4
Records
17
Agent score
94%

What's inside GoConvey

  1. Use the GoConvey Web UI

    master

    You can run a local web server that watches your tests and automatically updates the results in your browser as you change your code.

    1. Navigate to your project's path in the terminal.
    2. Run the goconvey command.
    3. Open http://localhost:8080 in your browser.

    The Web UI supports both GoConvey-style tests and traditional Go tests.

    $ $GOPATH/bin/goconvey
  2. Set up the Font Awesome development environment

    master

    To build the project or work on its source, you must install the following prerequisites:

    • Ruby and Ruby Development Headers (on Ubuntu: sudo apt-get install ruby-dev; on Windows: DevKit)
    • Bundler: Install via gem install bundler
    • NPM (Node Package Manager)
    • Less: Install via npm install -g less
    • Less Plugin: Clean CSS: Install via npm install -g less-plugin-clean-css

    After installing prerequisites, run these commands from the root of the repository to install development tools:

    $ bundle install
    $ npm install
  3. Write a GoConvey test spec

    master

    GoConvey uses a BDD-style (Behavior Driven Development) syntax. You use the Convey function to define scopes and the So function to define assertions.

    Important: Only pass the *testing.T object into the top-level Convey call. Nested Convey calls should only take the function body.

    package package_name
    
    import (
        "testing"
        . "github.com/smartystreets/goconvey/convey"
    )
    
    func TestSpec(t *testing.T) {
    
    	// Only pass t into top-level Convey calls
    	Convey("Given some integer with a starting value", t, func() {
    		x := 1
    
    		Convey("When the integer is incremented", func() {
    			x++
    
    			Convey("The value should be greater by one", func() {
    				So(x, ShouldEqual, 2)
    			})
    		})
    	})
    }
  4. Ignore or Reinstate paths via Ignore() and Reinstate()

    master

    These methods allow the user to manage which paths are monitored by the watcher.

    • Ignore(): Sends a messaging.WatcherIgnore command. Requires a paths query parameter (e.g., /ignore?paths=pkg/internal).
    • Reinstate(): Sends a messaging.WatcherReinstate command. Requires a paths query parameter to re-enable monitoring for specific paths.