Testing
242 bites tagged Testing — interview questions with model answers, and 60-second explainers.
Test Doubles: Mocks, Stubs, and Spies
A test double is a stand-in for a real component, letting you test code in isolation. Use them to fake slow dependencies like database calls or external APIs, making tests fast and predictable.
Chai: Assertions for Readable JavaScript Tests
Chai makes your JavaScript tests read like sentences. It provides assertion styles like `expect(value).to.equal(5)` to verify code behavior in test frameworks like Mocha. The main footgun: the `should` style fails silently on null or undefined values.
Mocha: A Flexible JavaScript Test Runner
Mocha is a flexible JavaScript test runner, providing structure but not assertions. It organizes and executes tests in Node.js and browsers, excelling with asynchronous code. The main footgun is forgetting you must pair it with an assertion library like Chai.
Jest: A Batteries-Included JavaScript Test Framework
Jest is a 'batteries-included' JavaScript test framework, bundling a runner, assertions, and mocks for a zero-config experience. It's a go-to for testing Node, React, and TypeScript apps. Footgun: Snapshot tests only catch unexpected changes, not flawed logic.
Shift-Left Resilience: Chaos in Your CI/CD Pipeline
Think of it as an automated stress test in your build pipeline that breaks things on purpose. It runs alongside integration tests, injecting faults like pod failures to find weaknesses before a merge.
Latency Injection: Testing How Your System Handles Slowdown
Latency injection intentionally slows down parts of your system to test its resilience. Use it to validate timeout configurations and circuit breakers before a real network lag causes a cascading failure. The footgun is injecting unrealistic delays.
Chaos Engineering: Finding Weaknesses Before They Find You
Chaos Engineering intentionally breaks parts of your system to find weaknesses before they cause real outages. It's used to test resilience against events like server crashes or network failures.
Scalability Testing: Will More Hardware Fix It?
Scalability testing answers 'Will more hardware fix it?' by measuring how performance improves when you add resources. The common footgun is confusing it with load testing, which just finds the breaking point under a given load.
Soak Testing: Finding Bugs That Only Time Reveals
Soak testing is like running a marathon, not a sprint, to find bugs that only time reveals. It applies a typical production load over a long period to uncover slow memory leaks or resource exhaustion. The footgun is confusing it with stress testing.
Benchmarking: Know Your System's Limits
Benchmarking finds your system's limits by measuring its responsiveness and stability under a controlled workload. Use it to catch performance regressions, compare tech choices, or for capacity planning. The footgun: trusting benchmarks run on your laptop.
Stress Testing: Finding Your System's Breaking Point
Stress testing finds a system's breaking point by pushing it beyond normal limits. It's used for mission-critical software to test robustness and availability under extreme load, not just normal function.
Load Testing: Simulating Real-World User Traffic
Load testing answers 'Can our system handle expected traffic?' by simulating many users at once. Use it before a big launch to find bottlenecks. The footgun is confusing it with stress testing, which pushes a system past its limits to see how it breaks.
Shadow Deployment: Test in Production, Safely
Shadow deployment copies live user traffic to a new "shadow" service for testing without user impact. It's used to validate new code versions with real-world load or to analyze traffic for security threats.
Game Days: Practice Breaking Your System Before It Breaks Itself
A Game Day is a live fire drill for your systems. You intentionally inject failure—like shutting down a service—to see how your team and automation respond, finding weaknesses before a real outage does.
Unit Testing ML: Beyond Standard Code Checks
Unit testing for ML isn't just about code logic; it's about checking data, models, and infrastructure in isolation. Use it to validate data transformers, check model prediction shapes, or confirm a function handles nulls.
Great Expectations: Unit Tests for Your Data
Great Expectations brings unit testing to your data, letting you assert what a dataset should look like. It validates data within a pipeline, preventing bad data from corrupting models or reports.
TestFlight: Apple's Beta Testing Framework
TestFlight is your private App Store for beta builds. Use it to distribute pre-release versions to internal teams and external testers for feedback before a public launch. The footgun: external tester builds require a beta App Review, unlike internal builds.
Snapshot Testing: Catch Unintended UI Changes
Snapshot testing compares your UI to a saved 'golden' image, failing if pixels differ. It's a visual diff for your views, catching unintended regressions in layout or style. The main footgun is forgetting to re-record snapshots after intentional UI changes.
XCUITest Page Object Model: Tame Your UI Tests
The Page Object Model treats each app screen as an object, separating test logic from UI interaction. In XCUITest, this creates stable tests for complex apps. The biggest footgun is forgetting synchronization—always wait for views to load before interacting.
measure: Baseline and Compare Code Performance
`measure` in XCTest establishes a performance baseline for a block of code and fails tests if it regresses. It tracks critical algorithm speed, running the code ten times for a stable average. The footgun is ignoring the baseline: you must set it first.
Xcode Code Coverage: Measuring Test Effectiveness
Code coverage isn't a grade, but a map of untested code. Use it in Xcode to find gaps in your logic before shipping. The footgun: high coverage doesn't mean your tests are good, just that the lines were executed, potentially missing key assertions.
Testing Async Code with XCTestExpectation
XCTestExpectation is a stopwatch for your tests, pausing them to wait for asynchronous work like a network call to finish. Use it for testing code with completion handlers. The footgun is forgetting to `fulfill()` the expectation, causing a timeout failure.
XCUIElementQuery: The Blueprint for Finding UI Elements
An XCUIElementQuery is a recipe for finding UI, not the element itself. It describes a search that runs only when you interact with the result. Use it in XCUITest to locate views for automated tests. The footgun: thinking a query finds an element on creation.
XCUITest: Automating Your App's User Interface
XCUITest is like a robot user for your app, tapping buttons and verifying what's on screen. It automates testing of critical flows like login or checkout to prevent regressions.
Get Testing bites daily.
Five a day, five minutes, offline. With quizzes so it sticks.
Open testing — you’ll join as an early tester.