Rails in the Large: How Agility Allows Us to Build One Of the World's Biggest Rails Apps
Neal Ford shows what ThoughtWorks learned from scaling Rails development: infrastructure, testing, messaging, optimization, performance.
Tracking change and innovation in the enterprise software development community
Posted by Craig Wickesser on Aug 14, 2008
JUnit is a unit testing framework for Java which has been around for years. It was originally developed by Kent Beck and Erich Gamma and is now maintained by the community which has recently released JUnit 4.5. In the many years that JUnit has been around numerous projects in the xUnit family have been spawned including: Even with years of development effort and usage on countless software projects around the world some continue to wonder if JUnit's fate is nearing its end. Often times when someone (or some group) of people begin to doubt the long term existence of a software project they will rely on web page viewing statistics. Just this week Mike blogged about the declining "interest" in JUnit based upon search engine results. Although he concludes by stating he doesn't believe JUnit is dead there seems to be some inclination that perhaps JUnit is being surpassed. One reason might be that as newer and better software practices evolve more and more developers catch on to them. Unit testing is certainly important and widely accepted, however, behavior driven development, mock objects and newer-featured unit testing frameworks are standing in the spotlight.| Feature | JUnit | TestNG |
| User Defined Life Cycle | ![]() |
![]() |
| Test Organization (groups, etc) | ![]() |
|
| Distributed Test Execution | ![]() |
|
| Parallel Test Execution | ![]() |
|
| Data Driven Tests | ![]() |
|
| Dependency Testing | ![]() |
|
| IDE Integration | ![]() |
![]() |
| Ant Integration | ![]() |
![]() |
| Maven Integration | ![]() |
![]() |
| Domain Specific Extensions (Database, HTTP, etc) | ![]() |
|
| Active Community | ![]() |
![]() |
JBoss versus IBM WebSphere: Cost, Performance, Efficiency, Innovation (IBM wins)
Unix, Linux Uptime & Reliability Increase While Patch Management Woes Plague Windows (Yankee Group)
Comparing WebLogic, WebSphere, Oracle, and Open Source Application Servers
I like the features of TestNG, but of course it's a little more complicated.
"JUnit has recently released version 4.5 of the infamous Java testing framework"
"*infamous*"? Did the Author smoke something Yesterday?.. Since when JUnit is infamous? Did I miss something?
Also above comparison of JUnit and TestNG is little bit unfair, IMHO.
IDE integration of JUnit is usually far, far ahead than TestNG. It usually comes with Your IDE, right there, build in, with all the goodies. I can simply pres my favurite keystroke and have test stub done for me. I can see reference for all my test, every coverage tool comes with support for JUnit, every CI server comes with integration fo JUnit...
Second, there are *gazilions* of plugins and JUnit integrations basically for everything You could even think about.
Last but not least - xUnit is supposed to be a *simple* tool. Just do the things it's supposed to do - Unit Test Your code. Lots of extra features TestNG has, for 80% of usages, are useless. Or at least I lived without them for last ten Years.
Artur
Correct me if I am wrong, but the only assumptions to say that JUnit is declining is that less people are visiting the JUnit website than the TestNG one?
JUnit is a mature framework, that many people use and that comes integrated in your IDE (as Artur rightly pointed out). I, for one, have been using JUnit for many years and I don't think I visited the website more than once (twice if you include today's visit for the sake of my argument); I just update my Eclipse regularly and JUnit gets updated along the way!
If need be, I am happy to visit the JUnit website every time I run a test :)
... Lots of extra features TestNG has, for 80% of usages, are useless. Or at least I lived without them for last ten Years.
This is the same kind of statement in the opposite direction as you did with asking whether the author did smoking something. So I answer you: "Have you lived behind a rock the last ten years or is your code being tested only "Hello World" stuff? :-)
I recommend you take a look at TestNG and then come up with something more substantial. It is good that you defend your choice but without making claims which proves nothing.
Michael
JUnit is a unit testing tool and it focuses on doing a good job of that.
TestNG - wants to be a unit testing tool and a whole lot more.
Neither is perfect, both make useful tools. Zealotry doesn't serve any of us well. I keep both tools in my arsenal and am agnostic as to which one I use.
Also contrary to the belief of some Junit is still actively developed and evolving.
Minor nit with the article: It can be argued that Dependency testing etc are not unit testing and hence the reason that its been left out of JUnit.
Also the claims that Cedric has made with respect to his influence of JUnits adoption of the NUnit like attributes have turned off more than a few members of the community.
Although in my blog post I said that I believe TestNG was a better framework, it's far from the leader regarding market share. JUnit still has the lion's share of the market. Between tool integration, developer familiarity and the fact that test driven development is still not as dominant as it should be, it will be a while before other tools gain enough traction to threaten JUnit's market dominance.
@Artur
I used "infamous" to indicate that JUnit is so widely known. Quite often if you ask a Java developer about unit testing JUnit is at least one of the tools they use or have heard of. And the comparison between JUnit and TestNG was meant to provide "brief" overview, not saying it was perfect or completely unbiased.
It is true that there are lot of extensions (I did make a reference to it near the end of the article).
@Mark
I agree I thinking having both in your tool belt is a good idea, as a developer, we should be open minded and adopt whatever works best for the work we are doing.
Nitpick FYI: I think what Artur was picking on was that you meant to say "famous" and not "infamous", which many, many people do inadvertently. From dictionary.com:
in·fa·mous
–adjective
1. having an extremely bad reputation: an infamous city.
2. deserving of or causing an evil reputation; shamefully malign; detestable: an infamous deed.
Michael. To answer Your question. Yes I looked at TestNG - it's nice, neat and funny. But how did its existence made JUnit "*infamous*"? You know, writing unit tests is about testing Your code, not testing brand new testing framework itself.
Artur
I am using TestNG for several years. Enough said.
Dont spent too much time talking about testing - use it to write test cases.
Junit is a solid good framework. It delivers what is needed and everything else is an add on. I think Junit will be here to stay for a pretty long time. Junit is mainly used to drive the design so in that point of view I think that any tool which lets me do that job of driving design and lightweight is good. TestNG's feature rich but that mustn't divert us from the primary use of these tools.
I don't see the need to call JUnit "infamous" to prove your point Wickesser. Btw, your analysis and "conclusion" is a little bit light for this kind of statement. Wouldn't it be better to compare TestNG to Junit and let the reader build their opinion? And I am not talking about a list of bullet points: a real case example would have better served your demonstration.
There is one major benefit that I think the article misses, though it is a companion benefit to one mentioned. I have been studying both Erlang and Objective-C lately in my spare time, and having an xUnit framework (EUnit and OCUnit respectively) provides a familiar tool with which to poke and prod these new (to me) territories.
It's very cool having experience in a tool transfer so seamlessly to other languages, and has significantly reduced my learning curve for new programming languages, frameworks and libraries. I hope xUnit's ubiquity insures it's long-term success (I think it will)... at least until something else becomes as pervasive.
I like TestNG better because it is easier for me to exclude or include tests that I want to run by setting it up in testng.xml.
I couldn't agree more. I've used TestNG on a Seam project and found the IDE integration lacking. JUnit has served me well and with the use of annotations that came with version 4 I quickly untied my Seam tests from TestNG and used JUnit.
James
www.jameswilliams.com.au
JUnit provides this too with the @Ignore annotation. TestNG does give you the ability to have different sets of tests (fast and slow for example) but it's tool support in Eclipse is shocking. The plugin does not reliably refresh and runs the tests based on a generated xml file that can get out of sync with the actual state of the code. I've spent time wondering why my changes don;t seem to make a difference to then realise I needed to clean my project. And don;t get me started about not being able to run a single test method in a test class. :-)
James
www.jameswilliams.com.au
As of JUnit 4 it is quite easy to disable (exclude) tests, by adding the @Ignore annotation on @Test methods (or as of version 4.3, on entire JUnit classes).
I find that easier than fiddling around in xml files.
I'm probably going to say the same that others have said. JUnit is the most popular Unit testing framework and I have worked in various companies and they all use JUnit. At the end of the day it's all about testing code that you have written and if JUnit works for you then thats ok. I personally don't care as long as there is a mature and solid framework that ensures proper testing for my code.
By the way..JUnit is certainly not infamous...
Has anyone wondered that maybe web searches and web site accesses for JUnit may be just the result of it being included by default with most IDEs? And the fact there are so many books and third-party articles that cover JUnit usage? People simply doesn't to "go to the source" for JUnit!
Additionally JUnit has got nice extension points for manipulating the set of tests to be run. Just extend Filter or Sorter. Especially when you decorate your testcases with custom annotations they become very powerful. :)
"JUnit has recently released version 4.5 of the infamous Java testing framework"
perhaps after this article JUnit 4.6 will become infamous by spawning a google search for JUnit every time a unit test passes
then everyone will know how wonderful JUnit is
Neal Ford shows what ThoughtWorks learned from scaling Rails development: infrastructure, testing, messaging, optimization, performance.
Stuart Halloway discusses Clojure and functional programing on the JVM in depth, and touches on the uses of a number of other modern JVM languages including JRuby, Groovy, Scala and Haskell.
Orion Henry and Blake Mizerany talk about the technology behind Heroku and the benefits of the new add-on system.
Chris Riley presents security issues threatening service based systems, examining security threats, presenting measures to reduce the risks, and mentioning available security frameworks.
This talk investigates technical issues encountered when moving to an Agile process.
Don Box and Amanda Laucher present “M”, a declarative language for building data models, domain models or external DSLs. Don Box's demos show some of M’s features and latest changes of the language.
It is four months since the SOA manifesto was announced; InfoQ interviewed the original author’s to get insight into the motivations and the process behind the initiative.
This article explains the impact memory barriers, or fences, have on the determinism of multi-threaded programs.
22 comments
Watch Thread Reply