Skip to content

Solution Components

Chris Pifer edited this page Oct 19, 2019 · 9 revisions

Solution Components

  • A testing flow - auto-launched, runs the system through the expected functionality, test/asserts expected results, returning success if all tests pass or an error message if a test condition failed.
  • A custom metadata record (TestFlowRun) - that identifies the flow that should run, and identifies the profile that should be used to run the flow.
  • An apex test class that gets the name of the flow, runs it, and asserts the returned variable is a string equal to 'success'

MVP

  • Sample Test Flows
    • Opportunity
      • This test flow creates an opp with Amount "1000" and verifies a workflow rule has run and the "Opportunity Size" field is set to "Medium"
      • This test flow is expected to fail, because of a logic mistake in the workflow rule, the resulting opportunity will have the "Opportunity Size" field set to blank instead of "Medium"
    • Test Flow - Account Update Process Builder
      • This test flow verifies that when the Phone field on an account is updated, all linked contacts' Phone fields should be updated with that value.
      • The flow variable result is a formula that the Apex class will read.
  • Test Class Runner - grabs flows identified in metadata and runs them.
  • Custom Metadata Type
    • TestFlowRun (Api Name of the flow, run as profile)

Future Enhancements

  • UI and tab for managing configuration - ideally, a user can manage all declarative tests in once place.
    • Create custom metadata records without dealing with clunky UI for creating and managing CMT records.
    • Deploys apex test methods over the tooling api for newly created flows.
  • Underlying Apex cleanup - current approach to underlying apex test structure isn't ideal.
    • Consider depreciating this and replacing it with a single test method, dynamically generated, appended to the test runner class, and named after the flow. This will provide better readable results.
    • Class template is provided in custom metadata in this repo. This template can probably be streamlined to become a method template that's similar to @IsTest methods in the current test runner class so more of the work is offloaded to a helper method that's part of the underlying package.
    • Template class and existing helper method need to better guarantee running user uniqueness (Username must be unique globally across test and production usernames).
  • Add an assert test if flow is active that displays a user-friendly warning that your test flow isn't active.
  • Consider returning an sobject from the flow with typed properties to provide for greater flexibility in communicating between flows and the underlying test classes.
  • Sandbox or test mode to provide greater visibility into the operation of the test flow.
Clone this wiki locally