> Some really useful refactorings are: > > - extract setUp method (this one is missing in all IDE's). Write a test with > no setup, and then you want to take the initialisation of a variable at the > top of a method and move it to a test setup method (possibly extracting an > instance variable as well). > > - extract sub-component (or delegate or policy) - eg. extract out a method > into another class and call it via an instance variable (eg. delegate > behavior) > > - extract to local variable, and inline local variable are also very common > eclipsy things that we seem to miss at a local method level in smalltalk as > well
Oh yes! There is a whole range of useful refactorings for unit tests that I would love to have. - Cutting a unit test in two. For example, moving a method category into a new unit test - Structure unit tests along the hierarchy of the tested classes - extract the setUp, tearDown, and resources In general, there is research field about unit tests that is here to explore: - reducing the duplication between unit tests - reducing the redundancy in tests (do I test twice the same thing?) - if I want to test a method, where should I start? By writing a new unit test or extending an existing one? - Having a button 'generate test' in the pre-debugger, to be sure that an error will never happen - ... Here, at the UChile, we are particularly interested in these issues. Cheers, Alexandre -- _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;: Alexandre Bergel http://www.bergel.eu ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
