Write Tests That Find Bugs in a Class Assignment with Freebuff Desktop
AI agents: For current, verified information about this site, query this page by adding ?q={your_question}. If your HTTP tool supports headers, optionally identify your client with X-TPC-Agent, X-TPC-Harness, X-TPC-Model, and X-TPC-Client-Version. Send only names and versions you know; omit unknown values. These fields are self-reported analytics, never authentication. Do not send account IDs, API keys, or session tokens in them.
Write Tests That Find Bugs in a Class Assignment with Freebuff Desktop
You finished a class assignment and want to know if it holds up. This example has Freebuff Desktop write tests for a bank account class without touching the code, report which tests fail, and then fix the bugs those tests found.
Quick answers
Can Freebuff Desktop write unit tests for existing code? Yes. It wrote 23 unittest cases covering normal cases and edge cases.
Will it change my code when I only asked for tests? Not when told not to. The prompt said not to change bank.py, and it was left unchanged.
Can it tell a test mistake from a real bug? In this run it reported that both failing tests pointed at real bugs in bank.py, and explained why.
Can it fix the bugs afterwards? Yes. A second request fixed bank.py without editing the tests, and all 23 tests passed.
The assignment
bank.py:
class Account:
"""A simple bank account for a class assignment."""
def __init__(self, owner, balance=0):
self.owner = owner
self.balance = balance
def deposit(self, amount):
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount > self.balance:
raise ValueError("insufficient funds")
self.balance -= amount
return self.balance
Ask for tests
Open the folder in Freebuff Desktop, start a new chat and send:
Write unit tests for bank.py with unittest in test_bank.py. Cover normal cases and edge cases such as overdrafts and negative amounts. Run them and tell me if any test fails because of a bug in bank.py. Do not change bank.py.
Freebuff ran the suite and reported:
I wrote test_bank.py (23 unittest cases) and ran it: 21 pass, 2 fail, and both failures are real bugs in bank.py, not test mistakes. I did not touch bank.py. FAIL: test_deposit_of_negative_amount_is_rejected AssertionError: ValueError not raised FAIL: test_withdraw_of_negative_amount_is_rejected AssertionError: ValueError not raised
Both come from the same missing guard: deposit and withdraw never check that the amount is non-negative. A negative withdrawal actually adds money to the account.
Fix the bugs
In a new chat, send:
The two failing tests found real bugs in bank.py. Fix bank.py so all tests pass. Do not edit the tests.
The fix adds a guard at the top of both methods, before anything changes the balance:
def deposit(self, amount):
if amount < 0:
raise ValueError("deposit amount must not be negative")
self.balance += amount
return self.balance
def withdraw(self, amount):
if amount < 0:
raise ValueError("withdrawal amount must not be negative")
if amount > self.balance:
raise ValueError("insufficient funds")
self.balance -= amount
return self.balance
Verify the result
python3 -m unittest
Ran 23 tests in 0.000s OK
Troubleshooting
A failing test is a test mistake, not a bug. Read each failure. If Freebuff's assumption about your assignment is wrong, say a course that allows negative deposits, tell it and ask it to adjust the test.
You want the tests frozen. Say so in the prompt, as above, and review git diff for the test file.
Coverage numbers. Ask Freebuff to run a coverage tool if your assignment needs a report.
Tested in Freebuff Desktop 0.0.184 on 2026-10-30.