Testing

December 11, 2023 · View on GitHub

Map of Outcomes to Testing Techniques

The table below maps outcomes -- the results that you may want to achieve in your validation efforts -- to one or more techniques that can be used to accomplish that outcome.

When I am working on...I want to get this outcome......so I should consider
DevelopmentProve backward compatibility with existing callers and clientsShadow testing
DevelopmentEnsure program logic is correct for a variety of expected, mainline, edge and unexpected inputsUnit testing; Functional tests; Consumer-driven Contract Testing; Integration testing
DevelopmentPrevent regressions in logical correctness; earlier is betterUnit testing; Functional tests; Consumer-driven Contract Testing; Integration testing; Rings (each of these are expanding scopes of coverage)
DevelopmentValidate interactions between components in isolation, ensuring that consumer and provider components are compatible and conform to a shared understanding documented in a contractConsumer-driven Contract Testing
Development; Integration testingValidate that multiple components function together across multiple interfaces in a call chain, incl network hopsIntegration testing; End-to-end (End-to-End testing) tests; Segmented end-to-end (End-to-End testing)
DevelopmentProve disaster recoverability – recover from corruption of dataDR drills
DevelopmentFind vulnerabilities in service Authentication or AuthorizationScenario (security)
DevelopmentProve implementation correctness in advance of a dependency or absent a dependencyUnit testing (with mocks); Unit testing (with emulators); Consumer-driven Contract Testing
DevelopmentEnsure that the user interface is accessibleAccessibility
DevelopmentEnsure that users can operate the interfaceUI testing (automated) (human usability observation)
DevelopmentPrevent regression in user experienceUI automation; End-to-End testing
DevelopmentDetect and prevent 'noisy neighbor' phenomenaLoad testing
DevelopmentDetect availability dropsSynthetic Transaction testing; Outside-in probes
DevelopmentPrevent regression in 'composite' scenario use cases / workflows (e.g. an e-commerce system might have many APIs that used together in a sequence perform a "shop-and-buy" scenario)End-to-End testing; Scenario
Development; OperationsPrevent regressions in runtime performance metrics e.g. latency / cost / resource consumption; earlier is betterRings; Synthetic Transaction testing / Transaction; Rollback Watchdogs
Development; OptimizationCompare any given metric between 2 candidate implementations or variations in functionalityFlighting; A/B testing
Development; StagingProve production system of provisioned capacity meets goals for reliability, availability, resource consumption, performanceLoad testing (stress); Spike; Soak; Performance testing
Development; StagingUnderstand key user experience performance characteristics – latency, chattiness, resiliency to network errorsLoad; Performance testing; Scenario (network partitioning)
Development; Staging; OperationDiscover melt points (the loads at which failure or maximum tolerable resource consumption occurs) for each individual component in the stackSqueeze; Load testing (stress)
Development; Staging; OperationDiscover overall system melt point (the loads at which the end-to-end system fails) and which component is the weakest link in the whole stackSqueeze; Load testing (stress)
Development; Staging; OperationMeasure capacity limits for given provisioning to predict or satisfy future provisioning needsSqueeze; Load testing (stress)
Development; Staging; OperationCreate / exercise failover runbookFailover drills
Development; Staging; OperationProve disaster recoverability – loss of data center (the meteor scenario); measure MTTRDR drills
Development; Staging; OperationUnderstand whether observability dashboards are correct, and telemetry is complete; flowingTrace Validation; Load testing (stress); Scenario; End-to-End testing
Development; Staging; OperationMeasure impact of seasonality of trafficLoad testing
Development; Staging; OperationProve Transaction and alerts correctly notify / take actionSynthetic Transaction testing (negative cases); Load testing
Development; Staging; Operation; OptimizingUnderstand scalability curve, i.e. how the system consumes resources with loadLoad testing (stress); Performance testing
Operation; OptimizingDiscover system behavior over long-haul timeSoak
OptimizingFind cost savings opportunitiesSqueeze
Staging; OperationMeasure impact of failover / scale-out (repartitioning, increasing provisioning) / scale-downFailover drills; Scale drills
Staging; OperationCreate/Exercise runbook for increasing/reducing provisioningScale drills
Staging; OperationMeasure behavior under rapid changes in trafficSpike
Staging; OptimizingDiscover cost metrics per unit load volume (what factors influence cost at what load points, e.g. cost per million concurrent users)Load (stress)
Development; OperationDiscover points where a system is not resilient to unpredictable yet inevitable failures (network outage, hardware failure, VM host servicing, rack/switch failures, random acts of the Malevolent Divine, solar flares, sharks that eat undersea cable relays, cosmic radiation, power outages, renegade backhoe operators, wolves chewing on junction boxes, …)Chaos
DevelopmentPerform unit testing on Power platform custom connectorsCustom Connector Testing

Sections within Testing

Technology Specific Testing

Build for Testing

Testing is a critical part of the development process. It is important to build your application with testing in mind. Here are some tips to help you build for testing:

  • Parameterize everything. Rather than hard-code any variables, consider making everything a configurable parameter with a reasonable default. This will allow you to easily change the behavior of your application during testing. Particularly during performance testing, it is common to test different values to see what impact that has on performance. If a range of defaults need to change together, consider one or more parameters which set "modes", changing the defaults of a group of parameters together.

  • Document at startup. When your application starts up, it should log all parameters. This ensures the person reviewing the logs and application behavior know exactly how the application is configured.

  • Log to console. Logging to external systems like Azure Monitor is desirable for traceability across services. This requires logs to be dispatched from the local system to the external system and that is a dependency that can fail. It is important that someone be able to console logs directly on the local system.

  • Log to external system. In addition to console logs, logging to an external system like Azure Monitor is desirable for traceability across services and durability of logs.

  • Log all activity. If the system is performing some activity (reading data from a database, calling an external service, etc.), it should log that activity. Ideally, there should be a log message saying the activity is starting and another log message saying the activity is complete. This allows someone reviewing the logs to understand what the application is doing and how long it is taking. Depending on how noisy this is, different messages can be associated with different log levels, but it is important to have the information available when it comes to debugging a deployed system.

  • Correlate distributed activities. If the system is performing some activity that is distributed across multiple systems, it is important to correlate the activity across those systems. This can be done using a Correlation ID that is passed from system to system. This allows someone reviewing the logs to understand the entire flow of activity. For more information, please see Observability in Microservices.

  • Log metadata. When logging, it is important to include metadata that is relevant to the activity. For example, a Tenant ID, Customer ID, or Order ID. This allows someone reviewing the logs to understand the context of the activity and filter to a manageable set of logs.

  • Log performance metrics. Even if you are using App Insights to capture how long dependency calls are taking, it is often useful to know long certain functions of your application took. It then becomes possible to evaluate the performance characteristics of your application as it is deployed on different compute platforms with different limitations on CPU, memory, and network bandwidth. For more information, please see Metrics.