Summary: | [JUnit] refactoring: Replace Query with Fixture | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | David Saff <david> |
Component: | UI | Assignee: | David Saff <david> |
Status: | NEW --- | QA Contact: | |
Severity: | enhancement | ||
Priority: | P3 | CC: | preuss |
Version: | 3.2 | ||
Target Milestone: | --- | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: | |||
Bug Depends on: | 39904 | ||
Bug Blocks: |
Description
David Saff
2005-10-06 13:41:51 EDT
I think there is an easier solution: The "Convert Local Variable to Field" refactoring could offer an additional "initialize in setUp" option. bug 39904 goes a long way. But, especially when using JMock, I often find myself wanting to move not just the first line of initialization, but a set of lines, like: fLaunchConfiguration = mockFor(ILaunchConfiguration.class); fLaunchConfiguration.stubs(); Come to think of it, given a fix for 39904, I can think of a workaround for this problem, so I'll let this depend on 39904. A quick assist might be better here. Actually, with JUnit 4, it gets a lot easier: @Before public void theComponent() { fComp = new Component(5); } (In reply to comment #5) > Actually, with JUnit 4, it gets a lot easier: > @Before > public void theComponent() { > fComp = new Component(5); > } Easier in which way? Easier in this way: for JUnit 4 tests, it is only necessary to mark the method as "@Before", rather than try to move the logic into the setUp() method. I see - you don't need to move code into a possibly already existing method. So what needs to be done for JUnit 4 is - extract method - mark the method with the @Before annotation - remove the method call from the test(s) Actually, I'm assuming the method is already extracted, so just the two remaining points. |