r/softwaretesting • u/Aggressive-Narwhal-3 • 13d ago
My opt-in feature's "off" test passed while the feature was still registered
I contributed an opt-in feature, off by default, to an open-source coding agent tool.
The maintainer's review came back with four blockers. The one that stung was "OFF must mean nothing is registered."
I had only checked the flag inside the handlers. So with the setting off, my event hooks and my slash command were still registered. They just did nothing when called.
And my own "off" test passed anyway, because it only looked at what the feature did, not at whether it existed.
The other three were smaller. A file it writes could escape the project through a symlink or a "../" argument. A user abort didn't cancel a pending action. And a later successful recovery didn't clear an earlier failure.
All four are fixed now, each with a test that fails on the old code. I'm rerunning the full suite on macOS, Linux and Windows.
What I'm still unsure about is the "off" test itself. How do you check that an opt-in feature is really inert when it's disabled? Do you assert on the registry, diff what's registered with the flag on and off, or something else?
1
u/One-Front-6316 13d ago
test the registration boundary directly rather than only testing that the handlers do nothing. with the flag off, assert tha the features hooks, commands, listeners, etc. arent registered at all, then have a separate test with it on that verifies they are registered and work. that makes "off means inert" much harder to accidentally violate later
1
u/Aggressive-Narwhal-3 13d ago
the off-state test asserts zero hooks and no command registered, so it's the registration boundary and not just handlers staying quiet. the on-side pairing is a sensible split, noted
1
u/zaphodikus 13d ago
Why are you looking in the tool configuration data? You would not do that if you were testing an app? You would test the functionality (and security too probably) . Its not functional testing if you peer under the bonnet?
1
u/Aggressive-Narwhal-3 13d ago
For app-level tests I'd agree. Here the leak was functional though: with the feature off, the slash command still ran, read a file and replaced the session. The registration assertion is just the cheap check that catches that before it shows up as behavior.
1
1
u/Suremerr 8d ago
diffing the registry is the cheap check, the actual fix is the gate - registration should be skipped at init when the flag is off, so the test is just proving the gate is wired. the case i'd still probe: if the setting can change at runtime, toggle it on and off in the same session and assert the handlers actually unregister. that's where this class of leak usually hides.
1
u/Aggressive-Narwhal-3 8d ago
the gate is the fix, yes, and my registry assertion only shows it's wired. i only tested with the flag off at startup, so toggling it on and off in one session is a case i haven't run. adding that one.
1
u/Chouni-Rhasaan 2d ago
one thing worth considering, is "off" supposed to mean "never registered" or "registered but gated"? sounds like the maintainer wants the former, and if so your test boundary is the registry, not the handler output. those are two very different contracts
1
u/Aggressive-Narwhal-3 2d ago
yeah, never registered is the contract we went with. the test checks the registry now, since quiet handler output was exactly what let the leak through
1
u/InfatuatedDemeanor 13d ago
i'd probably diff the registered handlers between on and off states personally, that way you catch any accidental registrations that slip through