Skip to content

Cover the JSON and environment branches no test reached - #1

Merged
dmccoystephenson merged 1 commit into
mainfrom
feature/json-and-environment-edge-tests
Sep 27, 2026
Merged

dmccoystephenson merged 1 commit into
mainfrom
feature/json-and-environment-edge-tests

Conversation

@dmccoystephenson

Copy link
Copy Markdown
Member

Summary

Stage B (unit-test expansion) cycle: the open-issue backlog was empty at triage, so this PR adds characterization tests for branches of TraceClient that no existing test exercised. Tests only. No production code, docs, csproj or workflow is changed.

New tests in tests/TraceClient.Tests/TraceClientTest.cs:

  • Json_OmitsAnInfiniteValueLikeNaN: +Infinity / -Infinity drop the value field (only NaN was covered before).
  • Json_WritesWholeAndNegativeValuesInTheirShortestForm: 42.0 goes on the wire as 42 and -0.5 as -0.5 (the README example reports 42.0).
  • Json_OmitsTheTagsObjectWhenNoTagSurvives: an empty map, or one where every tag is skipped, sends no "tags" key.
  • Json_RejectsAnApplicationLongerThanTheLimitButNotOneAtIt: the application side of the MaxLength check, which had no test.
  • Json_RejectsATagKeyLongerThanTheLimitAndNamesOnlyItsStart: the tag key length check (only the value side was tested), plus the 32-character cut in the logged reason.
  • Quote_EscapesCarriageReturnAndEveryOtherControlCharacter: \r, \u0000, \u001f, and non-ASCII passed through unescaped.
  • EnvironmentDisables_IsFalseWhenTheEnvironmentCannotBeRead: a throwing EnvironmentSource (e.g. SecurityException in a sandbox) yields false and leaves an enabled client. This covers the catch in EnvironmentDisables.

All the new tests call Json / Quote / EnvironmentDisables directly or build an enabled client against the shared StubServer. They don't depend on timing and use no new APIs outside what net48 provides.

Verification

  • Local anchor: UNVERIFIED. No dotnet SDK is installed in the dispatch sandbox, so the suite could not be run locally. The Build workflow matrix on this PR head (ubuntu-latest net8.0, windows-latest net8.0 + net48) is the gate.
  • No production behaviour changed, so no Tests-fix (revert) experiment applies.

Test plan

  • Build / ubuntu-latest (net8.0) green
  • Build / windows-latest (net8.0 + net48) green
  • Test count rises by 8 per target framework (7 new test methods; the Infinity theory has 2 cases)

Deferred

The issue backlog was empty at triage, so nothing was deferred.

No tracking issue: the gaps were found during triage by reading TraceClient.cs branch by branch against the test file.

This PR description was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).

🤖 Generated with Claude Code


drafted by Claude on behalf of Daniel Stephenson

Infinite values, whole and negative values, an empty or fully skipped
tag map, the application and tag-key length checks (including the
32-character cut in the reason), carriage return and the other control
characters in Quote, and an environment that cannot be read. Tests
only; they pin the current behaviour.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dmccoystephenson

Copy link
Copy Markdown
Member Author

Self-review rubric (anchored on the Build run 36214451437 on head 362e3f7):

  • Scope: PASS. git diff --stat origin/main shows one file, tests/TraceClient.Tests/TraceClientTest.cs, +88 lines, all new test methods. No reformatting of existing tests.
  • Tests-new: PASS (not applicable). No new public member was added.
  • Tests-fix: PASS (not applicable). No production code changed, so there is no fix to revert. These are characterization tests.
  • Sibling structure: PASS. The new tests follow the Subject_BehaviourInPlainWords naming, sit next to the existing Json_* tests, use out string inline declarations the same way Json_EscapesControlCharactersAndSkipsNullOrBlankTags does, and close the one enabled client they build.
  • Sibling renames: PASS (not applicable). Nothing was renamed.
  • Docs: PASS. No behaviour changed. The new tests agree with the README "What Report promises" row (sizes, null/blank tag skipping) and the "wire format" invariant-culture note.
  • Issue resolution: PASS (not applicable). There is no Closes #N, because the gaps were found during triage.
  • CI: PASS. Both legs are green. The test count rose from 37 to 45 on ubuntu net8.0, windows net8.0 and windows net48, which is the 8 expected (7 methods, and the Infinity theory has 2 cases). So the tests executed, not just compiled.
  • No dependencies / Single file / Vendoring floor: PASS. src/ is untouched, and the net48 leg is green.
  • Never throws / Non-blocking / Environment seam / Version / Opt-out contract: PASS (not applicable). The library is unchanged. EnvironmentDisables_IsFalseWhenTheEnvironmentCannotBeRead replaces TraceClient.EnvironmentSource in the test body, and the test class Dispose restores it. Parallelization stays disabled assembly-wide.

Notes for the reviewer:

  • tests/TraceClient.Tests/TraceClientTest.cs:382: non-ASCII is written as é / ü escapes, so the test does not depend on how the source file is encoded.
  • Json_WritesWholeAndNegativeValuesInTheirShortestForm pins the "R" format output (42, not 42.0). If the Java or Python clients write 42.0 for the same input, that is a cross-client parity question for a human, not something this PR changes.
  • The local anchor was UNVERIFIED because no dotnet SDK is present in the dispatch sandbox. The CI matrix on the exact head SHA served as the gate.

The one-pass self-review found nothing blocking. The PR is test-only and green on all three target/OS combinations.

This review comment was drafted during a Gardener session (https://github.com/Stephenson-Software/gardener).


drafted by Claude on behalf of Daniel Stephenson

@dmccoystephenson
dmccoystephenson merged commit 333d743 into main Sep 27, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant