What Makes a Great Test?
You know how to create a test now, but what separates a great test from one that constantly breaks or misses bugs? The difference isn’t just what you test—it’s how you structure your test. Think of it like building a house. You could throw materials together and technically have a structure, but a well-architected house with a solid foundation, proper framing, and quality materials will stand strong for decades. The same principle applies to tests. In this guide, you’ll learn the principles that make tests reliable, maintainable, and valuable.The Anatomy of a Well-Structured Test
Every great test has four essential parts:1. Setup (Getting to the Starting Point)
This is where you prepare your test environment and navigate to where you need to be. Example:- Log in to the application
- Navigate to the shopping cart
- Ensure you’re starting from a clean state
2. Actions (The Behavior You’re Testing)
These are the steps that simulate what a user actually does. Example:- Click “Add to Cart”
- Change quantity to 3
- Click “Proceed to Checkout”
3. Verifications (Checking Results)
This is where you confirm the application behaved correctly. Example:- Verify cart badge shows “3 items”
- Verify total price is correct
- Verify checkout page loaded
4. Cleanup (Optional)
Sometimes you need to clean up after a test (delete test data, log out, etc.). In many cases, Autonoma handles this automatically between test runs.Principle 1: Keep Tests Short and Focused
Why Short Tests Matter
The problem with long tests: Imagine a 50-step test that checks your entire e-commerce flow from browsing to purchase confirmation. When it fails on step 37, you have to wade through dozens of steps to understand what went wrong. The better approach: Break it into focused tests:- Test 1: “Browse products and add to cart” (10 steps)
- Test 2: “Update cart quantities” (8 steps)
- Test 3: “Complete checkout flow” (12 steps)
The Goldilocks Principle
- Too short (3-4 steps): Probably not testing a complete user journey
- Too long (40+ steps): Hard to debug, slow to run, tests too much at once
- Just right (8-20 steps): Tests one complete workflow, easy to understand and debug
Real-World Example
Bad (too long):Principle 2: Assert Frequently
What Are Assertions?
An assertion (or verification) is a checkpoint in your test that says: “At this point, I expect to see X. If I don’t see it, something is wrong.” Without assertions, your test just clicks around without actually verifying anything works.The Assertion Mindset
Think of assertions like checkpoints in a road trip:- You start in New York (Setup)
- You should pass through Philadelphia (Assertion 1)
- Then Baltimore (Assertion 2)
- Then Washington DC (Assertion 3)
- Finally arrive in Richmond (Final Assertion)
When to Add Assertions
Add assertions after every significant action:Bad vs. Good Assertion Patterns
Bad (too few assertions):Principle 3: Understanding Dynamic Content
What is Dynamic Content?
Dynamic content is anything in your application that changes:- Loading spinners that appear and disappear
- Data fetched from an API that takes time to load
- Notifications that auto-dismiss
- Real-time updates
- Content that differs based on time/location/user
Why Dynamic Content Needs Special Attention
The problem: Your test runs in milliseconds, but your application might take seconds to load data. Common failure scenario:Strategies for Handling Dynamic Content
Strategy 1: Assert on Dynamic Content Explicitly
Instead of assuming content is there, verify it appears: Instead of:Strategy 2: Use Waits for Loading States
Autonoma provides intelligent waiting mechanisms:Strategy 3: Prefer Stable Content for Assertions
Bad (flaky):Real-World Example: Testing a Dashboard
Bad approach (doesn’t handle dynamic content):- Number of notifications might vary
- Notifications might still be loading
- No verification that login actually completed
Principle 4: Overuse Waits and Scrolls
This might sound counterintuitive, but it’s one of the most important principles for robust tests.Why Waits and Scrolls Matter
Modern web and mobile applications are complex:- Content loads asynchronously
- Elements appear at different times
- Infinite scroll patterns
- Progressive loading
- Animations and transitions
Autonoma’s Intelligent Waits
Autonoma provides AI-assisted waits that are much smarter:waitUntil - Wait for Conditions
Instead of guessing how long something takes, tell Autonoma what you’re waiting for:
Traditional approach (fragile):
scrollUntil - Scroll to Find Content
For long pages or infinite scroll:
When to Use Waits
Use waits whenever you:- Click a button that triggers loading
- Submit a form that processes on the backend
- Navigate to a new page
- Trigger an animation or transition
- Load data from an API
- Wait for a modal to appear
When to Use Scrolls
Use scrolls when:- Content is below the fold
- Testing infinite scroll features
- Navigating long forms
- Finding elements in long lists
The “Overuse” Philosophy
Counter-intuitive truth: It’s better to have too many waits than too few. A wait that’s unnecessary: Completes instantly (no harm done) A missing wait: Causes flaky test failures that waste hours of debugging Example of “overusing” waits (recommended):Principle 5: Use Descriptive Prompts
Why Prompt Clarity Matters
When you come back to a test three months later (or when a colleague tries to understand it), clear prompts make all the difference.Bad vs. Good Prompts
Bad:- You can understand the test flow without running it
- You can spot errors in logic just by reading
- You can debug failures faster
- Others can modify the test confidently
Naming Conventions for Prompts
For clicks: Include what you’re clicking- “Click the submit button”
- “Click the ‘Create Account’ link”
- “Click the product image”
- “Type ‘[email protected]’ in email field”
- “Type ‘12345’ in zipcode field”
- “Type ‘John Doe’ in cardholder name”
- “Verify ‘Success!’ message appears”
- “Verify cart badge shows ‘3 items’”
- “Verify product name ‘Blue T-Shirt’ is displayed”
- “Wait until loading spinner disappears”
- “Wait until product list loads”
- “Wait until checkout page appears”
Putting It All Together: Before and After
Let’s see how these principles transform a real test:Before (Poorly Structured)
- Can’t tell what’s being tested
- No intermediate verifications
- Hard-coded wait time
- No handling of dynamic content
- Impossible to debug when it fails
After (Well Structured)
- Clear test purpose in the name
- Organized into logical sections
- Frequent verifications after each key action
- Intelligent waits instead of hard-coded delays
- Descriptive prompts that explain every step
- Easy to understand and maintain
Common Pitfalls to Avoid
Pitfall 1: Testing Too Much in One Test
Problem: “Test everything in one mega-test” Solution: Break into focused, single-purpose testsPitfall 2: No Verifications Until the End
Problem: Only checking results at the end Solution: Verify after each significant actionPitfall 3: Hard-Coding Dynamic Values
Problem:Verify: "Updated at 3:42 PM"
Solution: Verify: "Updated at" text appears
Pitfall 4: Not Waiting for Async Operations
Problem: Clicking before elements load Solution: UsewaitUntil liberally
Pitfall 5: Vague Prompts
Problem: “Click button”, “Verify message” Solution: “Click the ‘Submit’ button”, “Verify ‘Success!’ message appears”Quick Reference: Test Structure Checklist
Use this checklist when creating or reviewing tests:- Test name clearly describes what’s being tested
- Test is focused (one feature/workflow)
- Test is reasonably short (under 30 steps ideally)
- Verifications after every significant action
- Waits used for all async operations
- Scrolls used when accessing below-the-fold content
- All prompts are specific and descriptive
- Dynamic content is handled properly
- Setup phase gets test to starting point
- Cleanup is performed (if needed)
Key Takeaways
- Keep tests short and focused - one workflow per test
- Assert frequently - verify results after every significant action
- Handle dynamic content explicitly - don’t assume things have loaded
- Overuse waits and scrolls - better too many than too few
- Use descriptive prompts - your future self will thank you
- Structure tests logically - setup, actions, verifications, cleanup

