That covers how tests get written. Now the harder question: when a test passes, what does that actually prove? Start with where the right answer came from.
Test oracle
Whatever tells you what the right answer is. It may be a number you worked out by hand, a spec, an old system, or a rule that must always hold.
If an agent writes the code, runs it, and pastes the output in as the expected value, the oracle is the code itself. The test will pass for ever, and it proves nothing. Always ask where the expected value came from.
Say it to your agent
“Where did 1847.52 in this test come from? If you got it by running the code, delete it. Work it out from the rule in docs/pricing.md, show the sum in a comment, and use that.”