Test Coverage Analysis: JSON Converters and Utility Code #93
Replies: 4 comments
-
|
Item 1 complete — PR #94 merged. Added 8 property-based tests for the 4 simplest converters: |
Beta Was this translation helpful? Give feedback.
-
|
Item 2 complete — PR #95 merged. Added 9 property-based tests for 4 converters with nullable/optional fields: |
Beta Was this translation helpful? Give feedback.
-
|
Item 3 complete — PR #96 opened. Added 7 property-based tests for 3 converters with nested objects: |
Beta Was this translation helpful? Give feedback.
-
Items 4 and 5 completePR #97 covers the two remaining converter categories and the utility functions:
That wraps up the testing plan. All five items from this analysis now have PRs: #94 (simplest converters), #95 (nullable fields), #96 (nested objects), #97 (complex converters + utilities). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What's Currently Tested (17 tests)
The Big Gap: JSON Converters (24 primitives, 0 tests)
Every model has a
*JsonConverterprimitive — a pure function that takesJsonNavand returns a model object. These are the most valuable testing targets because:The converters range from trivial (
GitPersonJsonConverter: 2 fields) to complex (RepositoryJsonConverter: ~70 fields with nested objects, nullable fields, and optional sub-objects;GistJsonConverter: iterates a JSON object instead of array, has a defaultingcomments_enabledfield).Testing Approaches for Converters
Example-based: Construct a
JsonObjectwith the right keys/types, wrap it inJsonNav, call the converter, assert field values match. A minimal test and a test with nullable fields set tonullwould catch most bugs.Property-based (higher value):
Other Untested Code Worth Covering
JsonNavUtil.string_or_nonejson_nav_util.ponyJsonTypeStringrequest/json.ponyIssueCommentsURLissue_comment.ponyGistFileoptional fieldsgist_file.ponycontent/encoding/truncatedare absent in list responses but present in detail — both shapes should be testedGist.comments_enableddefaultgist.ponytruewhen missing — subtle behaviorGistfiles-as-object parsinggist.ponyPrioritized Recommendations
Start with the simplest converters —
GitPersonJsonConverter,LicenseJsonConverter,CommitFileJsonConverter,GistChangeStatusJsonConverter. These establish the test pattern (how to constructJsonNavin tests) with low complexity.Then tackle converters with nullable/optional fields —
LabelJsonConverter,IssuePullRequestJsonConverter,AssetJsonConverter,GistFileJsonConverter. These exercisestring_or_noneandtry/else Nonepaths.Then converters with nested objects —
GitCommitJsonConverter(nestsGitPerson),CommitJsonConverter(nestsGitCommit+CommitFilearray),IssueJsonConverter(nestsUser+Labelarray + optionalIssuePullRequest).Then the complex ones —
RepositoryJsonConverter(~70 fields),GistJsonConverter(object iteration, defaults).Add
JsonNavUtilandJsonTypeStringtests alongside the converter work, since converters depend on them.Property-based tests shine especially for the complex converters where manually enumerating all field combinations is impractical. The "field values are preserved" property is the single most valuable test you could write — it catches the most common bug class (reading the wrong JSON key).
Beta Was this translation helpful? Give feedback.
All reactions