Passing tests are reassuring. The next question I try to ask is which part of the behavior was actually checked.
A test can confirm that a file exists while missing what matters: whether its content is correct or a second execution replaces it when it should not.
The configuration fix for the previous portfolio gave me a concrete example. The solution needed to create a missing file while respecting one that already existed.
Start with something that could go wrong
When writing a test, I want to name the problem it is meant to prevent. Here there were two: a build failing because configuration was absent, and preparation overwriting local configuration.
Checking only file creation would leave the second situation open. The test could pass while an unwanted behavior remained.
Before adding more cases, I find it useful to ask: if someone introduces this error tomorrow, which test would flag it?
Separate what I am checking
The generator test prepares a temporary directory and runs the function without configuration. It then reads the file and compares its content with the expected fallback.
Later in the same test, it writes fictitious local configuration, runs preparation again and checks that the content has not changed.
That does not require a real key. I want to protect file creation and preservation, not a weather provider’s response.
Make expectations useful
A test name should help explain a failure before I open it. “Create missing configuration and preserve a local file” tells me more than “environment test.”
Expectations have the same responsibility. Checking only a return value can miss the important effect. Here I need to read what was written.
One scenario also does not establish that the generator works under every condition. The test covers the contract I prepared; other filesystem or permission failures may need separate attention.
Use AI to find cases I might miss
AI can suggest inputs, edge cases and initial tests. I find it useful to ask which error each case would detect as well as requesting the code.
Then I review the expectations. If they only copy what the implementation does, I might be checking the same assumption twice.
I can also ask what would happen if I removed a condition or allowed the file to be overwritten. That prepares a review; it does not mean I have run a mutation-testing campaign on the project.
Test the complete path when needed
Testing a function is not the same as compiling an application. For the portfolio error, an isolated copy without the configuration directory was also prepared and Angular was built with the fallback.
Those checks serve different purposes. One isolates preparation behavior; the other checks whether the resulting file is sufficient for that build.
The same distinction applies to the browser. A data test does not establish that an error message is readable or a button works with a keyboard. The scope needs to stay clear.
Keep tests I can explain
I do not want to increase the test count without understanding the benefit. I want each test to help me make changes with a clear reference for what must keep working.
When a test fails, I need to decide whether there is a defect or the expected behavior has changed. Knowing why the test exists makes that conversation easier, even when I work alone.
I discussed AI support in the Radar entry. With tests, that help is useful when it broadens the questions I ask about code while I continue reviewing the answers.
AN IDEA TO SHARE



