Skip to content

Tests using available entities 8e2#334

Merged
mkholt merged 22 commits into
masterfrom
tests-using-available-entities-8e2
Jun 18, 2026
Merged

Tests using available entities 8e2#334
mkholt merged 22 commits into
masterfrom
tests-using-available-entities-8e2

Conversation

@mkholt

@mkholt mkholt commented Jun 17, 2026

Copy link
Copy Markdown
Member

Migrate test suite to the fresh Dataverse environment

Why

The Dataverse test environment was re-creasted — several entities (Lead, Opportunity/OpportunityClose, Incident/IncidentResolution, Quote/QuoteClose/QuoteDetail, dg_bus, dg_child) and security roles are not part of the new environment. The test suite, metadata, and generated context were all built against the old environment, so we had to manually maintain the context. This PR migrates everything to the available schema and gets the suite fully green, with no loss of meaningful coverage.

Result

  • net8.0: 605 passing · 0 failing · 1 skipped (was failing at setup before this work).
  • Both target frameworks (net462, net8.0) build.
  • The single remaining skip (TestServiceRoles.TestCreateDefaultValues) is a pre-existing "disagreement over test" skip that predates this work.

What changed

Test migration to available entities

  • Migrated ~45 test files and the plugin/workflow fixtures from removed entities to custom ctx_parent/ctx_child + a minimal set of XrmMockup Test * security roles.
  • Added tests/TestEnvProvisioner — a console tool that idempotently provisions the custom entities, fields (incl. calculated/rollup/PowerFx), relationships, alternate keys, and roles into the environment, so a new dev can stand up a working environment without manual portal setup.
  • Regenerated metadata + XrmContext (compiles on net462 and net8.0).

Engine fixes (src/XrmMockup365)

  • Calculated fields: evaluated on-demand and projected onto the returned entity (they're not persisted, unlike rollups); previously the computed result was discarded.
  • Reserved workflow variable guard: CRM-generated calculated-field XAML declares a local True variable defaulting to False, which clobbered the engine's boolean constant and silenced every ConditionBranch — now guarded.
  • PowerFx formula fields: coerce results to the attribute's CLR type, and make per-field evaluation resilient (a formula erroring on a blank source no longer fails the whole Retrieve).
  • WorkflowManager.AddWorkflow now registers category-3 custom actions (previously mis-filed as workflows, so a runtime-added action was never invocable).

Removed-entity request handlers preserved

  • Incident/Quote/Opportunity request handlers (CloseIncident, Win/Close/Revise quote, Win/Lose opportunity) are still exercised: their entity metadata is hard-copied from the old generated metadata into RemovedEntitiesMetadata.xml (auto-merged via XrmMockup's multi-file metadata loading), and the tests were rewritten late-bound so they don't depend on the removed early-bound types. Two deleted plugins were re-created late-bound and registered via the fixture.

Workflows & plugins

  • Workflow test fixtures relocated to Metadata/OtherWorkflows/ (the generator wipes Metadata/Workflows/ on every regen); WaitingWorkflow retargeted off dg_bus to ctx_parent.
  • Non-DAXIF plugins that used to come from the environment's plugin solution are now registered via IPluginMetadata in the fixture.

Notes for reviewers

  • RemovedEntitiesMetadata.xml is intentionally hard-copied from the old environment's metadata (those entities can't be provisioned). It survives regen because the generator only rewrites Metadata.xml + the Workflows/SecurityRoles dirs.
  • EnforceStateTransitions on ctx_parent was enabled in the maker portal — the provisioner's SDK approach for that one entity-level flag doesn't reliably persist (noted in TestEnvProvisioner).
  • Skipped tests are documented inline with the reason; nothing was silently deleted.

🤖 Generated with Claude Code

mkholt and others added 22 commits June 12, 2026 10:00
Test: Generate mockup context using the in-source generator against the Tooling environment
Test: Add polyfills for the NET8+ validation attributes used in the context
…isables all Calc evaluation.

Fix: Actually return the calculated result (did this ever work?)
…ed down

Engine: calc fields evaluated on-demand (not persisted), PowerFx numeric
coercion + per-field eval resilience, reserved True/False workflow-variable
guard. Provisioner: ordered enforced-state-transition setup. Tests migrated
to ctx_parent/ctx_child + XrmMockup Test roles; removed-entity tests skipped
with reason; workflow fixtures relocated to regen-safe OtherWorkflows.

569 passing / 7 failing / 34 skipped (net8.0); both target frameworks build.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
These follow the same path as if they came from the environment
Fix: Allow us to inject an action by metadata and call that
…l skips

Restore TestIncident/TestQuote/TestOpportunity (CloseIncident/Win/Lose/Revise
request-handler tests) in original early-bound form behind #if
INCLUDE_REMOVED_ENTITY_TESTS, so the logic is visible/version-controlled and
build stays green; re-enable by provisioning the entities + regenerating the
context + defining the symbol.

Remove tests that no longer carry meaningful, in-scope coverage:
- TestActionExecution (ActionTest set 16 Lead-specific fields; action I/O is
  covered by TestActionParts)
- TestFormulaFieldEvaluated (redundant with TestCalculatedIsSetRetrieveMultiple)
- ContextJoinTest/ContextLoadDifferentEntitiesTest (Load/LoadEnumeration is
  XrmContext-generated code; testing it belongs in XrmContext's suite)

net8.0: 577 passing / 0 failing / 1 skipped; both target frameworks build.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
…metadata (copied from the old generated context)
…metadata

fileattachment is now one of the metadata generator's default entities, so Core
no longer fabricates its EntityMetadata at runtime. Dropped
Core.EnsureFileAttachmentMetadata (+ the SetMetadataProperty / CreateAttributeMetadata
reflection helpers) and the now-unused XrmDb.RegisterEntityMetadata.

InitializeFileBlocksUpload now throws a descriptive MockupException when the
fileattachment entity is absent from the loaded metadata, directing the user to
regenerate metadata that includes it (rather than silently using a synthetic
definition).

Full suite: 605 passing / 0 failing / 1 skipped; both target frameworks build.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
Master's merge added TestQueryExpression{NotEqual,NotIn,DoesNotBeginWith,
LinkEntityNotEqual}ExcludesNull written against the Lead early-bound type, which
doesn't exist on this branch (build failure). Migrated them to ctx_parent:
ctx_postalcode for the value (only p1 has one; the rest are null) and
ctx_contactid for the contact->ctx_parent link — same null-exclusion semantics.

Full suite: 609 passing / 0 failing / 1 skipped.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
…e key

PluginManager caches registered plugins in a process-static dictionary keyed by
GeneratePluginCacheKey, which only hashed basePluginTypes. Two XrmMockupSettings
with the same base types but different IPluginMetadata (e.g. XrmMockupFixture vs
TestLogging) collided on one key, so whichever Core initialized first populated
the shared cache and the other reused it — leaking/omitting plugin registrations
by test order. This passed locally but failed ~10 plugin tests in CI.

Include the plugin metadata (type, message, entity, stage, rank, mode, filtered
attributes, images) in the cache key so different plugin sets never share an
entry. Adds TestPluginCacheIsolation as a deterministic regression guard.

Full suite: 610 passing / 0 failing / 1 skipped; both target frameworks build.

Co-Authored-By: Claude <noreply@anthropic.com> via Conducktor <conducktor@contextand.com>
@mkholt mkholt merged commit e92c992 into master Jun 18, 2026
1 of 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