Repository navigation
report test2json: report tests as STEPs, handle skips, send system attributes - #29
DzmitryHumianiuk wants to merge 2 commits into
Conversation
…tributes ReportPortal counts execution statistics and assigns "To Investigate" only for STEP items without children. test2json reported every test as TEST, so its launches had no statistics at all, and subtests were flat next to their parent. - Report each test as a STEP and nest subtests under their running parent test, so every test case is counted exactly once. A test that already finished or is paused in t.Parallel() is never taken as the parent of a test named like it. - Handle the skip action: t.Skip() tests are SKIPPED instead of taking the package status. --skipped-issue (default true, as rp.skipped.issue in the Java agents) can mark them No Defect, and the launch carries the skippedIssue system attribute. - Send the agent, os and go system attributes (new pkg/gorp helpers SystemAttributes, SkippedIssueAttribute, NotIssue). - Print the launch link returned by the server with --print-launch-uuid. - Send SaveLog as a one-entry multipart batch: JSON on /log is deprecated in ReportPortal 6.x. - e2e: assert launch statistics, subtest nesting and skipped status. Fixes #22, #23, #24, #25 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟡 Changes recommended
A critical hierarchy bug can attach a child to the wrong parallel sibling, corrupting leaf statistics and prematurely closing an unrelated child.
1 open issue
What changed in this PR
This PR addresses #22–#25 across goRP’s test2json reporter and public library, improving ReportPortal execution statistics, skipped-test handling, launch metadata, and log compatibility.
Changes:
- Reports tests as nested
STEPitems and handles skips with configurable issue classification. - Adds system-attribute helpers and prints the server-provided launch link.
- Sends single logs as multipart batches and expands unit and end-to-end coverage.
| File | Description |
|---|---|
README.md |
Documents hierarchy, skip behavior, attributes, and launch-link output. |
pkg/gorp/reporting_client.go |
Routes single-log requests through multipart batching. |
pkg/gorp/reporting_client_test.go |
Verifies multipart single-log requests and responses. |
pkg/gorp/attributes.go |
Adds system-attribute and “No Defect” helpers. |
pkg/gorp/attributes_test.go |
Tests attribute values and issue classification. |
internal/commands/reporter.go |
Implements nested steps, skip handling, system attributes, and launch-link capture. |
internal/commands/report.go |
Adds the skip option, agent version lookup, and link output. |
internal/commands/report_test.go |
Updates tests for reporter options and return values. |
internal/commands/report_robustness_test.go |
Adapts robustness tests to the launch-link return value. |
internal/commands/report_hierarchy_test.go |
Adds hierarchy, skip, attribute, link, and empty-package tests. |
internal/commands/actions_test.go |
Adds the skipped-issue default to command fixtures. |
e2e/reporting_test.go |
Checks live execution statistics, nesting, skipped status, and link output. |
AGENTS.md |
Updates contributor guidance and reporter file references. |
.claude/skills/reportportal/SKILL.md |
Documents the new reporting options and behavior. |
Review effort: Balanced
| if ok && !r.paused[name] && slices.Contains(r.openItems, id) { | ||
| return id, ev.Test[i+1:] |
There was a problem hiding this comment.
Thanks. The case is real, but the stream doesn't contain enough information to resolve it. I ran both programs with go test -json (Go 1.27): a calling t.Run("b/c") and a/b calling t.Run("c"), with parallel siblings a and a/b both resumed. They produce the same event stream: run TestX/a/b/c with both tests running. No rule based on names or events can pick the right parent at start time, so some fallback is needed. I compared the two options:
- Longest prefix (kept): right when
a/branc, which I think is the more common pattern (for example, parallel table cases named/apiand/api/users). When it is wrong,cis shown under its sibling, but every test case is still counted exactly once.abecomes the leaf in place ofa/b, so the totals don't change. The early finish isn't harmful either. I sent that exact interleaving to a ReportPortal instance:a/bfinished before its misplaced child, and ReportPortal accepted both finishes. All items ended PASSED with correct launch totals, and the child was not closed early. - Nearest common ancestor / rejecting: this would flatten
cunderTestXand count one test case too many in both readings, so the hierarchy would be wrong every time instead of only some of the time.
What I changed in d4d2e5e:
parentOfnow also drops candidates that have a running subtest. Such a test is blocked int.Run, or its body has returned while its parallel subtests run, so it can't start a new subtest. This resolves the interleavings that can be decided.- The undecidable case and the reasoning for the longest-prefix fallback are now documented in the
parentOfcomment. - New tests:
TestReportLaunch_AmbiguousSubtestParentreplays the real stream for your interleaving and checks the documented fallback.TestReportLaunch_SubtestParentHasNoRunningSubtestcovers the new filter.
A running test with a running subtest is blocked in t.Run (or its body returned and its parallel subtests run), so it cannot start a new subtest. parentOf now drops such candidates before taking the longest running prefix. Document the remaining case test2json cannot decide (parallel siblings "a" and "a/b" both running) and why the longest prefix is kept there: test cases are still counted exactly once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Fixes #22, #23, #24, #25.
Problem
ReportPortal counts execution statistics, and assigns "To Investigate", only for
STEPitems without children.gorp report test2jsonreported every test asTEST, so its launches had no statistics at all. Two more problems:t.Skip()tests were never finished by gorp, so the server gave them the package's status (PASSED or FAILED).Before, on ReportPortal 6.0.0 with
master(pass, fail, skip, and a table test with three subtests):After, same input:
Changes
STEPs, and subtests are nested under their running parent test. Every test case is counted exactly once: a test with subtests is not counted itself.t.Parallel(), is never taken as the parent of a sibling named like it, e.g.t.Run("c/d")aftert.Run("c").testCaseId,uniqueIdandcodeRefare unchanged (pkg/Test/sub), so existing history is kept. Item names are now the last path segment.skipis handled. Skipped tests areSKIPPED.--skipped-issue(envSKIPPED_ISSUE, defaulttrue, asrp.skipped.issuein the Java agents). Set it tofalseto finish skipped tests withNOT_ISSUE.skippedIssuesystem attribute.skip("no test files") without a started suite is ignored, also with--reportEmptyPkg.agent=gorp|<version>,os=<GOOS>|<GOARCH>andgo=<version>, from new library helpersgorp.SystemAttributes,gorp.SkippedIssueAttributeandgorp.NotIssue.--print-launch-uuidnow also prints the link returned by the server (ReportPortal Launch: <url>).quality-gate check --stdinstill finds the UUID line.ReportingClient.SaveLogsends a one-entry multipart batch. JSON on/logis deprecated in 6.x; multipart works on 5.x and 6.x.nil, and the error is wrapped asunable to send log: ….Tests
/in their names;--skipped-issue;skipwith--reportEmptyPkg;SaveLogand the attribute helpers.go vet,go test -race ./...and golangci-lint v2.15.0: 0 issues.go test -jsonstreams, including parallel subtests and slash-named siblings.Not in this PR: launch join, rerun, retries for
-count,FailedBuildand the atomic command options (#26), shared library building blocks (#27), and theerrorCodedecoding issue (#28).Known server issue: on ReportPortal versions without reportportal/service-api#2935, a launch merged from launches that share an attribute (gorp now sends the same
agent/os/gosystem attributes) can't be deleted (reportportal/reportportal#2716).🤖 Generated with Claude Code