Brainstorm Edge Cases for Testing With ChatGPT

Writing tests is one of those tasks that’s both crucial and easy to overlook. Most of us start with the “happy path” — the ideal scenario where everything works as expected. But real users don’t always follow the happy path, and that’s where edge cases come in.

The problem? It’s easy to miss unusual inputs, boundary conditions, or unexpected scenarios when writing tests by hand. That’s where ChatGPT comes in handy: it can brainstorm edge cases I might not immediately think of and help me write more robust test suites.

Here’s how I use it.


Example 1: Email Validation

Let’s say I’ve written a function that validates email addresses. My initial test might only include something simple like:

Assert.True(IsValidEmail("alice@example.com"));
Assert.False(IsValidEmail("not-an-email"));

That’s fine, but what about the tricky edge cases?

I ask ChatGPT:
“What are possible edge cases for testing an email validation function?”

It suggests things like:

  • Empty string ("")
  • Missing @ symbol ("aliceexample.com")
  • Multiple @ symbols ("alice@@example.com")
  • Leading/trailing spaces (" alice@example.com ")
  • Special characters ("alice+promo@example.com")
  • Very long domain names ("alice@subdomain.subdomain.subdomain.example.com")
  • Unicode characters ("mañana@example.com")

Now I’ve got a much stronger test suite:

Assert.False(IsValidEmail(""));
Assert.False(IsValidEmail("aliceexample.com"));
Assert.False(IsValidEmail("alice@@example.com"));
Assert.False(IsValidEmail(" alice@example.com "));
Assert.True(IsValidEmail("alice+promo@example.com"));
Assert.True(IsValidEmail("mañana@example.com"));

Example 2: Password Strength Checker

Suppose I’m building a password strength validator. ChatGPT can quickly give me scenarios I might forget, like:

  • Minimum length ("12345")
  • Maximum length (500+ characters)
  • Only lowercase letters ("password")
  • Only numbers ("12345678")
  • Contains spaces ("Pass word1!")
  • Unicode or emoji (":)Strong123!")
  • SQL injection attempt ("' OR '1'='1")

By running these cases, I can make sure my password rules are actually enforced.


Example 3: Shopping Cart Quantity

For a shopping cart system, I might test normal cases like “1 item” or “5 items.” But ChatGPT can suggest cases such as:

  • Quantity = 0
  • Quantity = negative number
  • Quantity = extremely large number (e.g., 10,000,000)
  • Quantity = non-integer (1.5)
  • Quantity = null

These cases help me prevent overflow issues, validation errors, or even security exploits.


Why This Helps

  • Prevents Blind Spots – Surfaces test cases I may not think of on my own.
  • Improves Coverage – Leads to more resilient software by testing unusual inputs.
  • Saves Time – Quickly generates lists of cases instead of manually brainstorming.
  • Boosts Confidence – Helps ensure code is ready for real-world usage.

A Quick Note

ChatGPT isn’t a replacement for domain expertise — some edge cases will be unique to your business logic or data. But it’s an excellent starting point that can spark ideas and uncover blind spots.

I’ve found the best workflow is to:

  1. Paste in a description of the function/system.
  2. Ask ChatGPT for possible edge cases.
  3. Review and filter them for relevance.
  4. Turn the best ones into automated tests.

Final Thoughts

Testing the happy path is easy. Testing edge cases is where bugs usually hide. By using ChatGPT to brainstorm, I can build safer, more reliable software without spending hours trying to dream up every possible input.

Next time you’re writing tests, don’t stop at the obvious. Ask ChatGPT for edge cases — you might be surprised at the scenarios it comes up with.