deterministic
Always producing the same result from the same inputs, with nothing left to chance or timing.
In more detail
Deterministic code gives the same answer every run, which makes it testable and reproducible. Clocks, random numbers, hash randomisation, networks and the order of concurrent work are common sources of non-determinism.
Examples
A hash function must be deterministic, or a hash table could never find a key again.Screenshot tests need deterministic rendering: frozen animations, loaded fonts, a fixed viewport and one operating system image.In the browser: The cascade is deterministic thanks to source order as the final tie-breaker, and IndexedDB schema upgrades are deterministic because each version number runs a fixed set of steps.Build fingerprints sort file paths so identical code always hits the cache.Go: t.TempDir() gives each test its own temporary folderThe course sorts records and fixes timestamps so every run prints the same output; Kafka's key partitioner is deterministic too.In Terraform: Terraform's built-in functions are deterministic, so the same inputs always produce the same plan. Values that must be random, such as passwords, come from the random provider and are stored in state so they stay stable.In this course: Clocks, random numbers, shared databases, networks and run order all make tests non-deterministic. Make those inputs explicit and fixed, and the test gives the same verdict every time.Related terms
- hash function — A function that turns data of any size into a fixed-size value, called its hash, used to find items quickly in a table or to detect any change in the data.
- hash randomisation — Mixing a secret random value, chosen when a process starts, into string hashing so that hash values cannot be predicted from outside.
- test data — Known sample records loaded before tests so their results are predictable.
- stable ordering — An order of results that is the same every time the same request is made, which pagination depends on.
- mock — A test double that stands in for a real dependency and checks that the code under test calls it in the expected way.
- flaky test — A test that sometimes passes and sometimes fails on the same code, because it depends on something it does not control.
- visual regression testing — Testing that takes screenshots of components and compares them pixel by pixel with approved baseline images to catch unintended visual changes.
- percentage rollout — Releasing a feature to a chosen percentage of users, then raising the percentage as confidence grows.
- fixture — A named piece of setup, defined with @pytest.fixture, that a test receives by listing the fixture's name as a parameter.
- unit test — An automated check of one small piece of code, such as a single function, that runs quickly and on its own.
- source order — The order in which CSS rules appear; when everything else ties, the rule that comes later wins.
- hash — A short fixed-length fingerprint calculated from data, which changes completely if even one byte of the data changes.
- network mocking — Intercepting a test’s outgoing network requests and answering them with fixed fake responses.
- test double — Any object that replaces a real dependency in a test: a stub returns canned data, a fake is a small working implementation, and a mock checks interactions.
- http.RoundTripper — The Go interface for the part of an HTTP client that actually sends one request and returns one response.
- Clock (java.time) — The java.time class that supplies the current time, which code can receive as a dependency so tests can control what now means.
- pure function — A function whose result depends only on its arguments and which has no side effects, so the same inputs always give the same output.
- partitioner — The producer component that chooses which partition each record is sent to.
- attempt counter — A number stored in a record that counts how many times processing it has been tried.
- stateless — Describes a component or service that keeps no data from one request to the next, so each request carries everything needed to handle it.
- built-in function — One of Terraform's fixed set of functions, such as lower(), join() or jsonencode(), that transform values inside expressions.
- random provider — HashiCorp's provider that generates random values, such as passwords or names, and keeps them stable in state.
- frozen time — Making the current time a fixed value during a test, by passing an instant in or patching the clock.
- random seed — The starting value of a pseudo-random number generator; the same seed always produces the same sequence of numbers.
Taught in
- How The Next Token Is Chosen — AI Engineering: LLM Apps, RAG & Agents
- Prompts As Code — AI Engineering: LLM Apps, RAG & Agents
- Chunking And Ingestion — AI Engineering: LLM Apps, RAG & Agents
- Designing Tools A Model Can Use — AI Engineering: LLM Apps, RAG & Agents
- The Agent Loop — AI Engineering: LLM Apps, RAG & Agents
- Workflows Before Agents — AI Engineering: LLM Apps, RAG & Agents
- Excessive Agency — AI Engineering: LLM Apps, RAG & Agents
- Eval-Driven Development — AI Engineering: LLM Apps, RAG & Agents
- Model-Graded Evals — AI Engineering: LLM Apps, RAG & Agents
- Regression Tests In CI — AI Engineering: LLM Apps, RAG & Agents
- Capstone: The Tasks Assistant — AI Engineering: LLM Apps, RAG & Agents
- What A Hash Function Promises — Algorithms & Data Structures for Working Engineers
- Python Dicts And Sets Under The Hood — Algorithms & Data Structures for Working Engineers
- Collisions In Practice And Hash Flooding — Algorithms & Data Structures for Working Engineers
- Bloom Filters: Membership Without The Data — Algorithms & Data Structures for Working Engineers
- Recognising The Pattern — Algorithms & Data Structures for Working Engineers
- Pagination Strategies — Modern API Architecture: REST, GraphQL & gRPC
- Sorting Results — Modern API Architecture: REST, GraphQL & gRPC
- Unit And Integration Testing — Modern API Architecture: REST, GraphQL & gRPC
- Mocking Dependencies — Modern API Architecture: REST, GraphQL & gRPC
- Class Variance Authority: Type-Safe Variant & Prop Orchestration — Design Systems & Component Engineering
- Visual Regression Testing: Playwright & Snapshot Differencing — Design Systems & Component Engineering
- Decoupling Release From Deployment: Feature Flags — DevOps & Site Reliability Engineering
- Manual Object Mapping — Modern .NET Core, C# & Enterprise Microservices
- Unit Testing with xUnit and NSubstitute — Modern .NET Core, C# & Enterprise Microservices
- Integration Testing with WebApplicationFactory — Modern .NET Core, C# & Enterprise Microservices
- The Cascade Algorithm: Specificity, Inheritance And Source Order — Frontend Architecture & Web Platform
- IndexedDB In Practice: Object Stores, Indexes And Transactions — Frontend Architecture & Web Platform
- Monorepo Architecture: Workspaces & Turborepo — Production Full-Stack Engineering
- Unified Build Pipelines: Caching & Dependency Graphs — Production Full-Stack Engineering
- End-to-End Testing with Playwright: Multi-Tier Suites — Production Full-Stack Engineering
- Interfaces and Why They Are Implicit — Concurrent Systems Programming with Go
- The Standard testing Package — Concurrent Systems Programming with Go
- Calling APIs with net/http Client — Concurrent Systems Programming with Go
- Serving HTTP with net/http Server — Concurrent Systems Programming with Go
- Testing Basics With JUnit 5 — Modern Java: Virtual Threads & High-Throughput Services
- Designing Testable Code — Modern Java: Virtual Threads & High-Throughput Services
- Topics, Partitions And Where A Record Lands — Apache Kafka & Event Streaming
- Consumer Groups And Partition Assignment — Apache Kafka & Event Streaming
- Retries With Backoff Topics — Apache Kafka & Event Streaming
- Headers, Envelopes And Event Metadata — Apache Kafka & Event Streaming
- Functions And Expressions In HCL — Infrastructure as Code with Terraform
- What Test Doubles Are For — Automated Testing, TDD & Quality Engineering
- Testing Time And Randomness — Automated Testing, TDD & Quality Engineering
- Flaky Tests And How To Kill Them — Automated Testing, TDD & Quality Engineering
References
- NIST Dictionary of Algorithms and Data Structures: deterministic algorithm
- Python docs: unittest
- Playwright: visual comparisons
- Martin Fowler: Eradicating Non-Determinism in Tests
- Unit testing best practices
- MDN: Introducing the CSS cascade
- Turborepo: Caching
- Package testing: T.TempDir
- Java SE 21 API: Clock
- Python glossary
- Functions