@searls I wouldn't mind if the pre-factoring mode took precedence.
I take code refactoring as a close analogy to math, where you might re-compose terms of an expression to make the next operation easy.
The other reason to refactor isn't to make the next intended change easy, but to leave the code in a state that's more readable and less vulnerable to rot and confusion.
Factoring up common set-up in tests, and eliminating duplicate re-assertions across cases.
@RonJeffries @jmeowmeow @searls
The concept of removing the duplication between test and code was what made it click for me, and that's been the bulk of what I do during the refactoring step.
@orchun @jmeowmeow @searls
Hm, interesting. I don't often see much duplication of that kind, with the exception of occasional tests to figure out how some bit of the language works.
Are you kind of building up a function in the test and then moving/replicating it in the app?
@RonJeffries @orchun I tend to think of porting logic drafted in the test or test harness into the application as the Russ Rufer and Tracy Bialik TDD technique I encountered at the Silicon Valley Patterns Group.
I have seen a lot of duplication in test cases where new paths or variations are handled by copy-paste without factoring out common set-up or discarding redundant assertions.
@RonJeffries When I refactor a sequence of steps, and several dozen interaction tests break, often needing individual fixing, is an unpleasant experience which has shaped my attitude toward duplication in test cases.
(snipped: a tangent on alternative responses)
Orchestration logic appropriately uses interaction testing with mocks or other doubles. For domain logic, interaction testing isn't my first choice; input and output for representative domain examples is where I prefer to go.