Scripts2026年5月15日·1 分钟阅读

GoConvey — Go Testing with Browser UI

A BDD-style testing framework for Go that includes a live-reloading browser interface. Write expressive specs with nested Convey blocks and watch results update in real time.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
GoConvey Overview
通用 CLI 安装命令
npx tokrepo install 1289b187-5037-11f1-9bc6-00163e2b0d79

Introduction

GoConvey brings BDD-style test organization to Go with nested Convey blocks and a rich set of built-in assertions. Its standout feature is a web server that watches your source files, re-runs tests on save, and displays results in a browser with color-coded pass/fail indicators and desktop notifications.

What GoConvey Does

  • Organizes tests with nested Convey blocks for context-driven specs
  • Provides 30+ built-in So assertions like ShouldEqual, ShouldContainSubstring, ShouldBeNil
  • Runs a web UI that live-reloads test results on file changes
  • Sends desktop notifications on test pass/fail transitions
  • Integrates with standard go test without requiring a custom runner

Architecture Overview

GoConvey's DSL registers closures in a tree rooted at the top-level Convey call. The runner executes each path from root to leaf, re-running parent closures to isolate state. The web server watches the filesystem with fsnotify, triggers go test -json on changes, parses the JSON output, and pushes results to the browser over a WebSocket connection.

Setup & Configuration

  • Install the CLI with go install github.com/smartystreets/goconvey@latest
  • Run goconvey in your project root to start the web UI
  • Access the dashboard at http://localhost:8080
  • Change the port with goconvey -port=9090
  • Use goconvey -depth=2 to limit recursive package scanning depth

Key Features

  • Live-reloading browser UI with per-package pass/fail breakdown
  • Desktop notifications via the Web Notifications API
  • Built-in assertions cover equality, containment, nil checks, panics, and more
  • Custom assertions can be written as functions matching the assertion signature
  • Works alongside standard Go tests in the same file

Comparison with Similar Tools

  • Ginkgo — richer lifecycle hooks and parallel execution; no built-in browser UI
  • Testify — assertion-focused library without BDD nesting or web dashboard
  • testing (stdlib) — zero dependencies but no BDD structure or visual feedback
  • GoBDD — similar BDD approach with Gherkin-style Given/When/Then syntax

FAQ

Q: Can I use GoConvey without the web UI? A: Yes. GoConvey specs run with plain go test. The web UI is an optional tool for development-time feedback.

Q: Does GoConvey support parallel tests? A: Convey blocks within a single TestX function run sequentially. You can parallelize at the package level with go test -parallel.

Q: How do I write a custom assertion? A: Write a function with the signature func(actual interface{}, expected ...interface{}) string that returns an empty string on success or an error message on failure.

Q: Is GoConvey compatible with Testify? A: You can use both in the same project. Inside a Convey block, use So assertions for GoConvey-native reporting, or call Testify assertions with the testing.T from the outer function.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产