Testing
Testing fundamentals with no framework in sight: what each level buys you, what a double stands in for, how cases get chosen, and what coverage really measures. Interviewers start here.
on this pageshowhide
explore
- Levels of Testing24 questions
- Test Pyramid4 questions
- Unit Testing4 questions
- Integration Testing4 questions
- End-to-End Testing4 questions
- Acceptance Testing5 questions
- Contract Verification3 questions
- Test Doubles14 questions
- Meszaros Taxonomy4 questions
- Stubbing (Concept)3 questions
- Interaction Verification3 questions
- Substitution Boundaries4 questions
- Test Structure13 questions
- Arrange-Act-Assert (AAA)3 questions
- Test Isolation & Independence3 questions
- Flaky Tests4 questions
- Test Smells3 questions
- Test Design Techniques20 questions
- Equivalence Partitioning4 questions
- Boundary Value Analysis4 questions
- Decision Tables3 questions
- State Transitions4 questions
- Pairwise Combinations5 questions
- Coverage & Test Quality14 questions
- Code Coverage Metrics3 questions
- Coverage vs. Test Quality3 questions
- Mutation Testing4 questions
- Approval Testing4 questions
- AI & Data Scientistrole
- AI Engineerrole
- Backend Developerrole
- Data Engineerrole
- Frontend Developerrole
- Full Stack Developerrole
- Game Developerrole
- Java Backend Developerrole
- Java SDETrole
- Kotlin Backend Developerrole
- MLOps Engineerrole
- Machine Learning Engineerrole
- QA Engineerrole
- Software Architectrole
- iOS Developerrole
questions
85 · 5 sectionsWhat is acceptance testing, and what decides whether a change passes it?
basics
~20 sAcceptance testing judges a change against the stated acceptance criteria of the requirement it implements, not against the shape of the code. It passes when every criterion is demonstrably met, and those criteria are agreed before the work starts.
In a consumer-driven contract test, what does the recorded contract assert about the provider, and what does it deliberately not check?
basics
~20 sA consumer-driven contract records the requests one consumer sends and the response parts it actually reads, then asserts the provider can still produce them. It checks the shape of the boundary, not whether the provider's answers are correct.
What makes a test end-to-end rather than a narrower test, and what does it prove?
basics
~20 sAn end-to-end test drives the fully assembled, deployed system through a real entry point, with nothing inside the system replaced by a stand-in, and checks the observable outcome of a complete journey rather than any internal call or state.
What defects does an integration test against a real dependency catch that a fully mocked test cannot?
basics
~20 sIntegration tests catch defects that live in the boundary itself: wiring and configuration, serialization, schema and type mapping, and real query behaviour. A programmed double returns what you assumed, so it can never contradict that assumption.
What is the test pyramid, and why are narrow unit tests the widest layer?
basics
~20 sThe test pyramid is a shape guideline for an automated suite: many fast, narrow unit tests at the base, fewer tests across a real boundary above them, and a thin end-to-end layer on top. Width means test count.
Which collaborators in a unit test earn a stand-in, and which should be left real?
basics
~20 sReplace collaborators that cross a process boundary, are slow, or are nondeterministic, such as remote services, queues and clocks. Leave value objects, pure calculations and cheap in-process helpers real, because replacing those deletes the behaviour the test exists to check.
What are the five kinds of test double in Meszaros's taxonomy, and what separates them?
basics
~20 sA dummy is passed but never used. A fake has a working lightweight implementation. A stub returns canned answers. A spy records the calls it received. A mock holds expectations and fails the test itself when they are not met.
What is interaction verification in a unit test, and how does it differ from asserting on returned state?
basics
~20 sInteraction verification asserts how the unit called its collaborators - which method, how often, with which arguments. State verification only checks what came back or the state afterwards. Use interaction checks when the effect leaves nothing to return.
What is stubbing a collaborator's method in a unit test, and why do it?
basics
~10 sStubbing replaces a collaborator's method with a canned answer the test chose in advance. The unit under test then runs down a known path, without depending on the real dependency's data, speed or availability.
In the test-double taxonomy, how does a stub differ from a mock?
basics
~20 sA stub supplies canned answers so the code under test can run; it can never fail a test. A mock is configured in advance with the calls it must receive and fails the test itself when the run does not match.
What are the three phases of the Arrange-Act-Assert test structure?
basics
~20 sArrange builds the fixture, inputs and collaborators the test needs. Act invokes the one behaviour under test and captures its result. Assert compares that outcome with the expected one. Given-When-Then names the same three phases.
What is a flaky test, and why is it worse than a test that fails every time?
basics
~20 sA flaky test gives different verdicts on unchanged code, passing on one run and failing on the next. A consistent failure names a real problem; a flaky one teaches the team to re-run instead of investigate, destroying the suite's signal.
What makes a test independent of the other tests in its suite?
basics
~20 sAn independent test arranges everything it needs itself, writes to no state another test can observe, and leaves the environment as it found it. It gives the same verdict alone, in any position in the run, or beside tests on another worker.
What is the assertion roulette test smell, and what refactoring removes it?
basics
~20 sAssertion roulette is a test carrying many unnamed assertions, so a failure reports only a line number and you must guess which check broke. Remove it by naming each assertion or splitting the test so one behaviour gets one test.
What are the most common causes of a test that fails intermittently on unchanged code?
basics
~20 sThe usual families are timing assumptions, concurrency races, uncontrolled inputs such as the real clock, time zone or random values, calls to real external systems, dependence on the order cases run in, and state leaked between cases.
In boundary value analysis, which values do you test for a field that accepts 1 through 60?
basics
~20 sTest the edges, not the middle: 0 and 1 low, 60 and 61 high. Defects hide where a comparison flips from accept to reject, so each limit gets a value on it and one just past.
What is a decision table in test design, and what does each column represent?
basics
~20 sA decision table is a grid whose rows list the conditions of a rule set and the actions they produce. Each column is one rule: one combination of condition outcomes plus the actions it triggers. Each surviving rule becomes one test case.
What is equivalence partitioning, and how do you pick the value you test from each class?
basics
~20 sEquivalence partitioning splits the input domain into classes the software is specified to handle identically, then tests one representative from each valid and each invalid class. If a class really is uniform, one value speaks for all of it.
What is pairwise (all-pairs) test design, and why is it so much smaller than the full cross-product?
basics
~20 sPairwise test design picks a small set of configurations in which every pair of values from two different parameters appears together at least once. It is tiny compared with the full cross-product because a single row covers many pairs simultaneously.
What are states, events, guards and transitions in a state transition model?
basics
~20 sA state is a condition the system rests in between inputs. An event is an incoming trigger. A guard is a condition that must hold for that trigger to fire. A transition is the resulting move plus any action it performs.
What is an approval test, and how does it differ from a test with hand-written assertions?
basics
~20 sAn approval test runs the code, writes the output to a received artefact, and compares it against a previously approved artefact. Nobody types the expected value: a human reviews the output once and approves it, and the test then guards that exact output.
What is the difference between line coverage and branch coverage in a test run?
basics
~20 sLine coverage counts source lines executed at least once. Branch coverage counts which outcomes of each decision were taken, the true side and the false side. A line can execute while one of its two outcomes never runs.
Can a test suite with no assertions reach 100% line coverage, and what does that prove?
basics
~20 sYes. Coverage instrumentation records which code the tests executed, not whether anything checked the result. A suite that calls every function and asserts nothing still reports 100%, and proves only that the code runs without crashing.
What is mutation testing, and what does a surviving mutant tell you about a suite?
basics
~20 sMutation testing seeds small deliberate faults into the code and reruns the tests. A fault the tests catch is a killed mutant; one no test notices survives, showing that code is executed but never actually asserted on.
Why must an approval test normalise timestamps and generated ids before comparing output?
basics
~20 sBecause values that change every run make the received artefact differ from the approved one even when the code has not changed. The test then fails nondeterministically, so teams re-approve reflexively and the approval stops meaning anything.