XpdWiki

FrontPage
RecentChanges
XtC
FindPage
PageIndex
XpApprentices

Set your name in
UserPreferences

Edit this page

Referenced by
IbmEclipseTips




JSPWiki v2.0.52


TestFirstProgrammingInEclipse


I think people doing Test First Programming will be particularly interested in one of the latest IbmEclipse features.

  • If you write a test which includes references to non-existant classes/interfaces/methods then a little light bulb pops up. Clicking on this bulb offers to create the neccessary class or method stubs for you.

For instance take this code snippet from testFred.java:

Fred aFred = new Fred("moo"); aFred.walk();

  • Eclipse will offer to create the Class Fred (or interface if so desired), the single argument constructor and add the walk method - without you typing anything.
  • By the time you've finished your first test you will have the real object stub ready and just have to fill in the method details - that bit is easy anyway after writing the test ;-)
  • There are some improvements I would like, but it's still pretty time saving. Particularly if you are doing test first anyway (of course you are!)

  • This page refers to Stable Build F3 (http://www.eclipse.org/downloads/index.php)

MpC

Fantastic: one eclipse oponent was telling me InteliJ? did this and I didn't have an answer. I'd never thought to click those new things. I have to say that so many things have been added, I've had to re-read all the preference and option screens to discover all the new features, these eclipse wiki pages are certainly helping me discover new ways of using this continually evolving tool. -- OliBye

My only beef is that it puts it in the current package. Which is always a test package, if you're doing TFD -- OliBye

On the other hand, if you write a line in a test like assertTrue(foo.bar(baz,bif));

and click on the lightbulb inviting you to create Foo.bar(Baz,Bif) (which is a nice feature to have) declares bar() as returning String, not boolean (which is irksome).


On an associated note, can anyone offer any suggestions for applying more control to the built-in JUnit support in Eclipse? I can't seem to find a way of making it save/compile any open editors before running, for example. I also have problems with any tests which access the filesystem, as I'm not able to set (or even easily tell!) which working directory it uses when running JUnit. --FrankCarver

The working directory is the workspace directory, i.e. the one above your projects. I had to discover this by writing a test which created a file then searching for the file!. W.r.t to saving all files: In the Debug preferences "Build (if required) before launching" will save code. If you're talking about other sorts of files, then in the Workspace preference you can "Save all modified resources automatically prior to manual build". Then do a manual build I suppose. I've never had a problem with this. -- OliBye =====


Edit this page   More info...   Attach file...
This page last changed on 17-Mar-2003 21:13:02 GMT by unknown.