- Repository:
git://eleglicity.com/other_apps/gwt-framework.git - Go import metadata:
https://eleglicity.com/go-modules/gwt-framework/ - Release tarball and checksum
Go import metadata is used by go get; it is not documentation and is intentionally blank in a browser.
Versionless commands resolve to the latest published release (v0.3.0):
go install eleglicity.com/go-modules/gwt-framework/cmd/gwt
Explicit @latest forms:
go install eleglicity.com/go-modules/gwt-framework/cmd/gwt@latest
Versions
| Version | Commit | Go commands | Artifacts |
|---|---|---|---|
v0.3.0 (latest) |
f75f3d951ff5fbd3258df77b5a424be931903eaa |
go install eleglicity.com/go-modules/gwt-framework/cmd/gwt@v0.3.0 |
tools image / tarball |
v0.2.0 |
cb3ce384058273844e8486042c65e89f174cc615 |
go install eleglicity.com/go-modules/gwt-framework/cmd/gwt@v0.2.0 |
— |
v0.1.0 |
d8a60a0781f9d89913095808b1cdb711236c946f |
go install eleglicity.com/go-modules/gwt-framework/cmd/gwt@v0.1.0 |
— |
Overview
The GWT framework is the canonical producer and SDK for Given/When/Then test enrichment. Go, shell, and Python suites emit Schema V per-class reports that the standalone renderer consumes.
It is not the renderer: this module provides the test libraries, shell shim, converter CLI, release tarball, and framework-baked tools image.
Install
Use the published Go module:
go get eleglicity.com/go-modules/gwt-framework
The release tarball and checksum are published under
https://eleglicity.com/gwt-framework/. The gwt-framework-tools image
bakes that published tarball for host test suites.
Usage
How the pieces fit
gwt-framework produces Schema V per-class JSON. It does not aggregate or
serve reports. gwt-renderer is a stateless HTTP consumer that turns those
documents into the JSONP viewer bundle.
test -> per-class JSON (Schema V) -> POST /v1/report -> JSONP viewer bundle
Pin one immutable framework release (gwt-framework.lock) and one renderer
version. Never pin latest in automation; it is for human browsing.
Shared prerequisites
- Framework: the published module, static
gwtCLI, shell shim, or tools image (gwt-framework-tools:<version>);gwt versionmust match the lock. - Renderer: base URL
https://eleglicity.com/gwt-renderer/<version>.GET /healthGET /v1/compatibilityPOST /v1/reportGET /openapi.jsonandGET /docs/
- Check compatibility before the first report:
RENDERER="https://eleglicity.com/gwt-renderer/<version>"
curl -fsS "$RENDERER/health"
gwt compat check --renderer "$RENDERER" --require-known-good
Go client projects
- Pin the module in
go.mod(noreplace):
require eleglicity.com/go-modules/gwt-framework vX.Y.Z
Then run go mod tidy.
- Use
pkg/gwt/testingin tests:
package calc_test
import (
"testing"
gwt_testing "eleglicity.com/go-modules/gwt-framework/pkg/gwt/testing"
)
func TestAdd(t *testing.T) {
g := gwt_testing.New(t, "go")
g.Given("two numbers", "1", "2")
g.When("they are added")
g.Then("the sum is 3")
if got := 1 + 2; got != 3 {
t.Fatalf("sum = %d, want 3", got)
}
g.AssertContains("sum=3", "3")
}
- For data-driven tests, add sample data and
Specification/Execute:
func TestAddRows(t *testing.T) {
g := gwt_testing.New(t, "go")
g.WithSampleData(func(cfg *gwt_testing.SampleDataConfig) {
cfg.WithDataHeaderRow("a", "b", "want").
WithDataRow("1", "2", "3").
WithDataRow("10", "20", "30")
})
g.Specification(func() {
a, _ := strconv.Atoi(g.GetDataCurrentRow("a"))
b, _ := strconv.Atoi(g.GetDataCurrentRow("b"))
want, _ := strconv.Atoi(g.GetDataCurrentRow("want"))
g.Given("two numbers")
g.When("they are added")
g.Then("the sum matches the data row")
if a+b != want {
t.Fatalf("sum = %d, want %d", a+b, want)
}
})
g.Execute()
}
- Emit and validate:
GWT_OUTPUT_DIR="$PWD/gwt" go test ./...
gwt schema validate gwt/go/*.json
gwt_testing.New(t, "go") writes gwt/go/<package>.<Class>.json.
cmd/gwtreport in a consumer is optional project-specific tooling for
go test -json; it is not part of this framework.
- Render the report (see the shared renderer step below) with
name="go"andgwt/go/*.json.
Shell client projects
- Provision the pinned framework. The tools image provides
/opt/gwt; otherwise fetch the lock's tarball and verify its SHA-256.
GWT_HOME="${GWT_FRAMEWORK_DIR:-/opt/gwt}"
[ -x "$GWT_HOME/bin/gwt" ] || {
echo "install gwt-framework-tools or set GWT_FRAMEWORK_DIR" >&2
exit 1
}
export PATH="$GWT_HOME/bin:$PATH"
export GWT_OUTPUT_DIR="$PWD/gwt/shell"
- Source base assertions, then the shim:
source "$PROJECT_DIR/tests/lib/test_helpers.sh" # ok/fail/skip
source "$GWT_HOME/shell/gwt_enrich.sh" # GWT event recording
The shim installs trap gwt_finalize EXIT. If you install your own trap,
chain it: trap 'cleanup; gwt_finalize' EXIT.
- Write the test inside a
test_*function so the method name auto-captures:
test_addition() {
gwt_given "two numbers"
gwt_when "they are added"
gwt_then "the sum is 3"
if [ $((1 + 2)) -eq 3 ]; then
ok "sum is 3"
else
fail "sum was not 3"
fi
}
test_addition
- Convert and validate. The shim calls
gwt convert -stricton exit; to run it explicitly:
gwt convert -strict "$GWT_OUTPUT_DIR"
gwt schema validate "$GWT_OUTPUT_DIR"/*.json
Orphaned methods (registered but never completed) become FAILED.
A missing gwt binary is a loud failure, never a silent skip.
- Render with
name="shell-tests"andgwt/shell/*.json.
Python client projects
- Install the wheel. The generated contract models are wheel-only, so the source tree is not the supported install path:
python/build-wheel.sh dist
pip install dist/gwt_python-*.whl
- Register the pytest plugin in
conftest.py:
pytest_plugins = ["gwt_framework.pytest_plugin"]
- Write the test:
def test_addition(gwt):
def spec():
a, b = 1, 2
gwt.GIVEN("two numbers", str(a), str(b))
gwt.WHEN("they are added")
gwt.THEN("the sum is 3")
assert a + b == 3
gwt.with_method_title("Addition works") \
.specification(spec) \
.execute()
- Emit and validate:
GWT_OUTPUT_DIR="$PWD/gwt" pytest
gwt schema validate gwt/python/**/*.json
The plugin writes gwt/python/<package>/<Class>.json.
- Render with
name="python-tests"andgwt/python/**/*.json.
Renderer integration (all client types)
Post one or more modules; each payload is:
{
"modules": [
{ "name": "go", "classes": [ /* Schema V per-class documents */ ] }
]
}
Example for the Go output:
RENDERER="https://eleglicity.com/gwt-renderer/<version>" # pin, never latest
name=go
jq -s --arg name "$name" '{modules:[{name:$name,classes:.}]}' gwt/go/*.json \
> gwt/request.json
curl -fsS -H 'Content-Type: application/json' \
--data-binary @gwt/request.json "$RENDERER/v1/report" > gwt/response.json
mkdir -p gwt/report
for f in index.html viewer.js viewer.css data.jsonp modules.jsonp "data.$name.jsonp"; do
jq -r --arg f "$f" '.files[$f] // empty' gwt/response.json > "gwt/report/$f"
done
The response .files map is the viewer bundle: index.html, viewer.js,
viewer.css, data.jsonp, modules.jsonp, and data.<name>.jsonp. Publish
that directory from your app or CI artifact store; the framework never serves
reports. A non-2xx response is a hard failure. Do not fall back to a fake viewer
in production.
Verifying the contract
gwt schema version
gwt schema validate <path...>
gwt compat check --renderer "$RENDERER" --require-known-good
gwt compat check verifies the renderer's transport API, accepted data
contract, and optional exact known-good release. Use it in CI before posting a
report.
Mechanism
Every producer writes the Schema V per-class JSON shape: package and class metadata, methods, Given/When/Then labels, results, and optional sample data. The Go test library, shell event parser, and Python plugin all target that shape.
The standalone renderer consumes the per-class JSON; this module does not aggregate or serve reports. The root module stays stdlib-only, and the consumer lock pins one immutable release.
Maintenance
Release one immutable tag at a clean HEAD; the release tooling builds the
static gwt CLI, the sha256-verified tarball, the tools image, and the
consumer lock from that tag. Versions and checksums in the catalog come
from gwt-framework.lock, not from this document.
Upgrade consumers by updating the lock to a new immutable tag. Run
GOWORK=off go test ./... in the repository and in this nested docs
module before publishing. The documentation contract is owned by the
site-catalog module; widening it requires a new schema release.