Skip to content

Evolve per-type testing #33521

Open

Description

@roji

#30981 shows that we're currently lacking test coverage for querying types within JSON. Our testing for specific database types is spread out across various places:

  • BuiltInDataTypesTestBase: basic type testing support. Uses a single model, so quite difficult (even if possible) to extend for extra types beyond the initial closed list.
  • JsonTypesTestBase: serialization/deserialization within JSON only - both scalars and collections - but not end-to-end (uses JsonValueReaderWriter), and no querying.
  • JsonQueryTestBase: JSON querying tests, including query testing for a closed list of types (so not easily extensible by providers)
  • JsonUpdateTestBase: JSON update tests, for the same closed list of types.

Ideally, we'd have one ad-hoc test suite, with infra to perform all testing for a given database type via a single test; the test would dynamically build an ad-hoc model with a regular column of the type, a JSON document with a scalar of the type, and a collection of the type; and it would exercise serialization, deserialization and querying of all of the above. The test class would contain testing for a basic type list, but providers would be able to easily call the same test infra method for their own arbitrary types. Opt outs would allow not testing specific aspects - like JSON serialization - where that happens to not be supported etc.

For inspiration, see the AssertType() infra in Npgsql (code), where a single call tests all functionality related to the support of a single type.

Cases to tests;

  • Partial update of scalar property within JSON via SaveChanges.
  • Partial update of scalar property within JSON via ExecuteUpdate (done in #36659).
  • Mapping via primitive collection, saving, querying...

Activity

  1. added this to the Backlog milestone on Apr 29, 2024
  2. changed the title [-]Comprehensive relational type testing for both serialization and querying[/-] [+]Comprehensive type testing for both serialization and querying[/+] on Jul 31, 2024
  3. removed their assignment
    on Aug 31, 2024
  4. added theissue type on Jun 15, 2025
  5. roji commented on Sep 2, 2025

    @roji
    MemberAuthor

    Idea to self: rather than a single TestType method, maybe have a test suite per type. This way, each different scenario gets its own test method, with the model being shared between all tests.

  6. changed the title [-]Comprehensive type testing for both serialization and querying[/-] [+]Evolve per-type testing[/+] on Sep 3, 2025
  7. roji commented on Sep 3, 2025

    @roji
    MemberAuthor

    The basic test suite has been introduced in #36659, with a suite-per-type architecture; I'm pretty confident this will be a good basis and will allow us to expand our per-type coverage.

    Keeping this issue to track evolving the test suite and integrating more coverage.

  8. marked Refactor BuiltInDataTypes #27650 as a duplicate of this issue on Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions