Module 9 of 10
The Complete Anti-Pattern Gallery
A museum of testing mistakes. Study these exhibits carefullyβrecognizing what not to do is just as important as knowing what to do.

Dear Marilyn: I inherited a test suite that everyone says is "unmaintainable." How do I know what is wrong with it?
β Inheritor in Indianapolis
Dear Inheritor: Walk through this gallery with me. I will show you the 13 most common anti-patterns in test automation. By the time we finish, you will be able to diagnose your test suite like a doctor reading an X-ray.
The 13 Anti-Patterns
#1Hardcoded
Test data and element identifiers are embedded directly in the test code.
Any change to the UI or data requires modifying the test itself.
click(element: "#btn_submit_v2") enter_text(field: "txtUsername", value: "[email protected]")
click(element: [Submit_Button]) enter_text(field: [Username_Field], value: [Test_User])
Use interface definitions for elements and data sets for test data.
#2Spaghetti
Actions call other actions in a tangled web of dependencies.
Impossible to understand the flow. Changes break unexpected tests.
action: process_order
calls: validate_customer
calls: check_credit
calls: get_balance
calls: validate_customer (circular!)action: process_order step: validate_customer() step: check_credit() step: create_shipment()
Keep action hierarchies shallow. Actions should call down, never sideways or up.
#3Klunky
High-level tests contain low-level implementation details.
Business users cannot read the tests. Maintenance is difficult.
click(element: "#nav-menu") wait(ms: 500) click(element: "#menu-item-3") wait(ms: 300) click(element: "#submenu-2")
navigate_to(page: "Invoice Management")
Encapsulate low-level steps in mid-level actions. Keep high-level tests readable.
#4Lifeless
Tests do not cover the complete lifecycle of a business object.
Missing coverage for create, update, delete, or state transitions.
Test Module: Invoice - create_invoice β - view_invoice β - (no edit, delete, approve, reject tests)
Test Module: Invoice - create_invoice β - edit_invoice β - delete_invoice β - approve_invoice β - reject_invoice β
Use the CRUD + State Transitions checklist for every business object.
#5Lame
Tests lack depthβonly happy path, no edge cases or error conditions.
Bugs hide in the corners that are never tested.
Test: Create Invoice - Valid data β Success β (no negative tests)
Test: Create Invoice - Valid data β Success β - Empty customer β Error β - Negative amount β Error β - Future date β Warning β
For every positive test, add at least 2-3 negative tests.
#6Clueless
Tests have no clear scope or objectiveβthey test 'everything' and 'nothing'.
No one knows what the test is supposed to verify.
Test: General System Test Objective: "Test the system"
Test: Invoice Calculation Accuracy Objective: "Verify that invoice totals are calculated correctly including tax, discounts, and multi-currency conversion"
Every test module must have a specific, measurable objective.
#7Sneaky Checking
Verification logic is hidden inside actions instead of explicit check actions.
Failures are hard to diagnose. Checks cannot be reused or skipped.
action: create_invoice (internally verifies total) (internally checks status) (throws if wrong)
create_invoice() check_invoice_total(expected: "$100") check_invoice_status(expected: "Draft")
Make all checks explicit. Actions do things; checks verify things.
#8Action Explosion
Hundreds of actions with minimal reuseβeach test has its own actions.
Maintenance nightmare. No consistency across tests.
Actions: 500+ - create_invoice_for_acme - create_invoice_for_globex - create_invoice_for_initech (each slightly different)
Actions: 50 - create_invoice(customer, amount) (parameterized, reusable)
Parameterize actions. One action with arguments beats ten specialized actions.
#9Techno
Action names use technical jargon instead of business language.
Business users cannot understand or validate the tests.
execute_sql_insert_tbl_inv post_http_api_v2_orders trigger_onclick_btn_submit
create_invoice submit_order click_submit_button
Use verb_noun naming with business terminology. No SQL, HTTP, or DOM references.
#10Endless
Test cases are extremely long with dozens or hundreds of steps.
Hard to debug. First failure masks all subsequent issues.
Test Case: Complete Order Flow Steps: 1-150 (login β browse β cart β checkout β payment β shipping β confirmation β ...)
Test Case: Add to Cart (10 steps) Test Case: Checkout (12 steps) Test Case: Payment (8 steps)
Break long tests into focused scenarios. Each test should verify one thing well.
#11Swiss Army Knife
A single action tries to do too many things based on parameters.
Complex, fragile, and impossible to understand.
process_entity( type: "invoice|order|customer", operation: "create|update|delete|view", validate: true|false, notify: true|false )
create_invoice() update_order() delete_customer()
One action, one purpose. Split multi-purpose actions into focused ones.
#12Over-Checking
Every single step has verification, creating noise and brittleness.
Tests fail on irrelevant changes. Signal lost in noise.
click_menu() check_menu_expanded() click_item() check_item_highlighted() check_page_loading() check_page_loaded() check_title() check_breadcrumb()
navigate_to(page: "Invoices") check_page_title(expected: "Invoice Management")
Check outcomes, not intermediate states. Verify what matters to the business.
#13Fragile Locators
Element identification relies on brittle attributes that change frequently.
Tests break with every UI update, even cosmetic ones.
click(element: "div.container > form > div:nth-child(3) > button.btn-primary")
click(element: [Submit_Button]) # Interface Definition: Submit_Button = "#btn-submit" OR "button[data-testid=submit]"
Use stable identifiers (data-testid, IDs). Abstract locators into interface definitions.
Quick Diagnostic Checklist
Use this checklist to quickly assess a test suite for anti-patterns:
Module Summary
The 13 anti-patterns fall into three categories:
Structure Problems
Hardcoded, Spaghetti, Klunky, Fragile Locators
Coverage Problems
Lifeless, Lame, Clueless, Over-Checking
Design Problems
Sneaky Checking, Action Explosion, Techno, Endless, Swiss Army Knife