In our larger Java projects, we do use Scala for some of the unit tests, particularly with Specs. Specs is very good, though I'm sure a DSL for Java that does similar things could be concocted easily, and probably already exists.
On Wed, Oct 27, 2010 at 8:55 PM, Kevin Wright <[email protected]> wrote: > > 2010/10/27 Cédric Beust ♔ <[email protected]> >> >> >> On Wed, Oct 27, 2010 at 11:55 AM, Mark Volkmann >> <[email protected]> wrote: >>> >>> >>> I wonder though if most people still give their test methods names >>> that begin with "test". I do. One reason is so the test methods stand >>> out in my IDE within the list of methods in the class. I want some way >>> to visually distinguish between test methods and utility methods >>> within the test class. >> >> Yes but this can be easily solved with a tool. Writing an updated Eclipse >> Outline view to group methods by annotations is a matter of a few hours. Hey >> I might even go ahead and write it myself. >> The thing is: most of the methods in my tests classes are test methods, so >> the need for this is not that high, at least to me. >> As for naming, yes, old habits die hard and it's easy to just start your >> method name with "test", but I find myself being more and more creative with >> this now ("shouldThrowException", "userShouldBePresent", etc...). And I >> always have the handy `description` attribute if I am in a verbose mood >> (@Test(description = "Make sure we have exactly one user named Smith in the >> db"), something that you can't do without annotations. > > I'm sorry, but, yes that can be done without annotations: > > http://www.scalatest.org/getting_started_with_fun_suite > http://code.google.com/p/specs/ > and before anyone starts screaming "Oh no, not Scala again!", there's no > reason why you can't restrict it to just testing - It's quite possibly the > best use case I've seen so far for an internal DSL, and it doesn't touch > production code in any way. > You won't find yourself using annotations to subvert the type-system or > extend the language in any way and, frankly, if you're in the position that > you need to add extra support to the IDE anyway, then you may as well do it > for something that's just a *little* bit more flexible than adding a few > test cases! > > Having said all that, I totally agree that having the word "test" in method > or class names is a pretty Bad Thing(tm). If you're working with BDD then > you'll be writing specifications, not tests. > >> >> -- >> Cédric >> >> -- >> You received this message because you are subscribed to the Google Groups >> "The Java Posse" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/javaposse?hl=en. > > > > -- > Kevin Wright > > mail / gtalk / msn : [email protected] > pulse / skype: kev.lee.wright > twitter: @thecoda > > -- > You received this message because you are subscribed to the Google Groups > "The Java Posse" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/javaposse?hl=en. > -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.
