JUnit bible thumpers

It’s fairly impressive how unit testing seems to have grabbed a number of java developers by the balls, and made them sing in surprisingly high voices.

Of course, we all know the virtues of unit testing. It’s great, it lets you err…test your little unit of code. It lets you pretend you don’t need any QA engineers, and rewards you with nice green bars (or ascii dots, if you’re into that sort of thing) that seem to have a disturbing sexual appeal to far too many people.

What is surprising though is the religious aspect of it. For example, some comment on a blog a few weeks back had someone spouting shite like ‘well I’m not a zealot or anything, but I would never use code with no unit tests, it works by accident not design’. What’s particularly sickening about this is the fuckfaced disclaimer up front. It puts the whole thing right up there with such gems as ‘Well I’m no racist but those niggers…’ and ‘I’m no bible thumper but YOUR ALL BURNING IN HELL YOU GODDAM ABORTION LOVING BABYKILLERS’ (Note: The typo is deliberate).

Surprisingly, the developer world hobbled along quite successfully before junit. Huge portions of it keep on hobbling that way with astounding success. See, what people seem to have forgotten is that a unit test does not mandate junit. It’s the approach that matters. Coverage reports are there to make things more sexually stimulating, they’re NOT a fundamental part of the approach. You could have plenty of unit tests that are nothing more that main methods in your various implementation classes. That still has its value, and certainly is more useful than no tests at all.

The JUnit fetishists are the freakiest of them all. What’s impressive is that they’ve invented this whole new universe just to justify what a horrifically broken tool they’ve staked their careers on (yes thoughtworks fuckstains, I’m pointing and laughing at you, you dirty chozgobbling rumprangers). Need static initialisation for shared or expensive resources? Not possible in Junit! Therefore, it’s evil! if you need to do it you’re broken!

The same goes for anyone who ever expresses any need for something beyond one method one test. Why the religious zealotry here? We all write code every day that requires more than one method, so why can’t our tests function similarly? Why is it so unthinkable that there might be some element of good unit testing that are not fully captured by JUnit?

The sickest joke in all this is how badly JUnit itself is written. Just read some of the javadocs and inline comments, they make it fairly clear that a fairly liberal amount of drugs had been imbibed in the course of writing it all.

So I ask you, all of you who want nothing more in life than to bend over and have JUnit plug all your orifices, why? What do you get out of it? Why this sickening allegiance to a flawed, old, unmaintained, and dysfunctional tool?

Update

: In my fury at junit, I forgot to mention my shameless plug. If you’re a JCP member, vote for me in the EC elections! If you aren’t, join then vote for me. I’m the only nominee who is motivated purely by improving Java. Everyone else is there out of some business need or corporate agenda. Stick it to the man!

66 Responses to “JUnit bible thumpers”

  1. Anonymous Says:

    What’s your point? Solution? Answer? Anything?

  2. Anonymous Says:

    It’s a _BILE_ you dumbass, it’s supposed to point out a problem, not propose a solution.

  3. tdak Says:

    I would like to see a list of similar (read better) tools for Unit testing.

  4. Nathan Lee Says:

    Yeah, somethings seriously screwed with the API of JUnit, add to that the problem you have when you want to extend it to do something useful and all the tool tool writers have tied themselves in at the wrong level..

    Add to that the copious amounts of harness code you need to write JUST to stop yourself from going postal trying to write a simple test.

    I think junit’s one of those things people like to say that it’s useful, but at the end of the day we need something a lot better (perhaps agitar or something along those lines).

  5. Anonymous Says:

    Huh? Of course you can test more than one method call per unit test method. Of course static initialisers are a bad idea. Of course expensive and static initialisers that might fail are a terrible idea. It looks like you don’t like JUnit because it gets in the way of your awful coding style, but that can’t be the case, can it? Can it?

  6. Zeke_ Says:

    9 days between biles is a bit too long .. please don’t let that happen again

  7. Anonymous Says:

    It’s unfortunate, but it seems Hani has missed the whole point of the unit-testing movement. You are especially way off when you start spewing about Junit being revered. It’s popularity is due to it’s ubiquity and that’s about it. I mean.. the tool barely does anything by itself. If you are trying to unit test any system more complex than a high school project, your gonna have to build on top of JUnit extensively and threw in some other frameworks. As well, I don’t think anyone proposed to replace QA engineers with JUnit unit tests. Perhaps, you need to take a good hard look again at what and how people are using JUnit.

  8. Anonymous Says:

    Can I press a button in my IDE and clearly see whether or not all of your main methods “pass”? I didn’t think so. JUnit isn’t perfect but everyone knows how to use it and it’s integrated into most IDEs and build tools.

    You should have mentioned the mysterious exception handling. If you don’t catch Exception somewhere and print to stderr you don’t get much feedback at all.

  9. tghfbt Says:

    Get doctest and relax

    http://c2.com/cgi/wiki?DocTest

  10. Mike McLean Says:

    I think it’s stupid stuff like this that the good man is talking about:
    http://www.theserverside.com/news/thread.tss?thread_id=29114

    I don’t need a fuckface telling me bullshit like that. This is the real world where real work needs to get done.

  11. Howard Lewis Ship Says:

    Artima’s SuiteRunner seems like a much improved version of JUnit; I wish someone would cut-n-paste Eclipse’s JUnit support to create SuiteRunner support. I can’t live without my green bar (and my usefully filtered stack traces, and an easy way to re-run failed tests, etc.).

  12. Cedric Says:

    Hani’s Bile Etiquette prevents him from giving a solution to his bile, but I’m not stopped by such ludicrous moral conduct.

    The solution is, of course, TestNG, which will soon be available for JDK 1.4 as well. http://beust.com/testng

  13. Jimbo Jones Says:

    Pretty pathetic this time, Hani

  14. Ketools Says:

    I agree, JUnit is crap. It has very limited application. I’m not knocking testing your code, I’m just saying that JUnit for me is not a workable solution for anything more complicated than testing some static helper methods. Almost
    everything that I have ever wanted to test, executes in some context. Don’t tell me that ‘setup()’ and ‘tearDown()’ is there to define context, because it’s a crap way of doing it. Any state that I want to associate with the test, needs to be fetched from some singleton abortion, which is there purely to hack your way around a how a unit test gets constructed.

    Wie’s jou pa klein hondtjie!

  15. Anonymous Bastard Says:

    “The typo is deliberate”
    As far as I can tell, you spelled “niggers” correctly.

  16. Anonymous Bastard Says:

    Finally a bile about JUnit. I requested this almost a year ago on December 31st. Ask, and you shall receive.
    Anywho, Hani’s right on this one. People actually design to fit JUnit. How incredibly stupid is it to make your design fit your tool?
    “Nail, meet Hammer.”
    “Oh, you’re not a nail? Well, better make you into one then.”

  17. Harold Pudwell Says:

    I like the way Maven runs all my JUnit tests after compiling the code. Oops, did I just admit to being an asshat?

  18. James Gosling Says:

    No fucking way are you getting on EC, whatever the fuck that is, asshole.

  19. the_mindstorm Says:

    I see Cedric didn’t resist much and announced TestNG support for JDK 1.4. Yep, it will come out very soon indeed.

  20. jimmy gosling was never called an asshole Says:

    “chozgobbling rumprangers” heh.

  21. Dude Says:

    I don’t think James Gosling would use any of those words on any post. He is a very intelligent human being, and Canadian. So whoever is trying to pretend to be James Gosling. “No fucking way are you going to fool us, asshole.”

  22. fletch Says:

    ek is jou pa

  23. Eelco Says:

    Unit testing saved my ass several times when refactoring. And JUnit just provides a minimal framework for writing the tests. Whine on pimple faces!

  24. James Gosling Says:

    While it’s true that I’m intelligent and canadian, there’s more to the story than that. When I was young, my entire family was wiped out in a freak snowshoeing accident. Subsequently, I was raised by wolves for the next 9 years of my life. After emerging from the wilderness and learning English, Pascal and C++, I toured the underground canadian cage fighting circuit, vanquishing such foes as Andre the Giant, RMS and an entire squadron of fat balding jordanian pilots. One fateful night, as I was pounding the living piss out of a wimpy academic LISP programmer, a particularly drunk, rabidly drooling sloth introduced himself to me in between heaves of vomit as John Schwartz. He then proceeded to slip roofies in my drink, and when I awoke, he had shaved of all of my chesthair and had me tied to a bed. He said that the only way he would let me go was if I went to go work for him at his computer company. Being a caged animal, I complied. So you can see, I have a perfectly good reason to curse like a fucking sailor and you can take your snooty comments about canadians and shove them up your ass.

  25. Angsuman Chakraborty Says:

    JUnit does have its share of problems as I also mentioned in my blog on 8/0/04 http://blog.taragana.com/index.php?p=56

    I found a way to get around the limitation of one-test-per-method.

    As always Cedric rapidly comes to the rescue of anyone posting woes of JUnit with reference to his tool NGUnit :)

    I did play around a bit with NGUnit. I like the ability to make any method a test method and the lack of requirement to extend/implement some class/interface. The xml way of specifying tests leave much to be desired and takes away much of the simplicity of other features. The grouping and sub-grouping features surely didn’t listen to YAGNI thoughts :) More on it later, maybe in a blog.

  26. Anonymous Says:

    Ward invented the wiki. Kent and Ward invented JUnit. Pretty successful ideas.

    You can’t even get ‘asshat’ catch on.

  27. Java guy Says:

    You got my Vote..you deserve it :)

  28. Davide Inglima - limaCAT Says:

    Anonymous: the real issue is not JUnit or Kent & Ward. The real issue is that JUnit has (technologically) made its time, that JUnit is not the “only true Unit Testing solution”, that JUnit is NOT the “only way to acquire salvation”, that Unit Testing by itself covers only ONE aspect of development therefore all the fetishism is lost.

    If you read carefully the bileblog, you will see that Hani puts fetishisms in the first place of hatred.

  29. Aggrieved Says:

    Let’s just kill Martin Fowler and get it over with. Put a bead into his baldy noggin and end all this torment.

  30. Alexey Kudravtsev Says:

    I just love the language. Except JBoss related biles, when it seems Hani’s tongue became too tangled because of excessive anger, it’s simply brilliant.
    Hani, you are my Jerome Jerome!

  31. Sam Newman Says:

    There is also JBehave, which is being developed by some thoughtworks fuckstains I know – http://www.jbehave.org/

    TestNG uses annotations – that makes me sad.

  32. Screw Ball Says:

    Wow! And I was just about to get around to finally using this JUnit thing.

    Hani saved me in the nick of time!

  33. not quite anonymous Says:

    Anon: “Ward invented the wiki. Kent and Ward invented JUnit. Pretty successful ideas.”

    Ward? From Cocobase? Kent? From Smallville?

    Wiki is just a stupid name for a bulletin board system disguised as a blog.

    JUnit is just a combination of Class.forName() with Runnable.run() .. how brilliant ..

    Instead you should try TestGYN, which is my own personal wiki-based unit-testing software that I’m trying to build a consultancy around. Thanks!

  34. Dude Says:

    Hey everyone we have a James Gosling hater here who seems to pretend he is James Gosling. Why don’t you go wack off you little winky in the corner and stop telling us about your dream of being raped in a cage by Johnathan Shwartz. Another thing – Go Fuck Yourself and that litle whore of yours you call your mother.

  35. Anonymous Bastard Says:

    Hey everyone we have a Dude who doesn’t seem to get it.

  36. Dude Says:

    I get it. Don’t you worry about that. There is just no need to impersonate yourself as James Gosling and confuse other people.

  37. fx Says:

    The only thing Cocobase Ward ever invented was the idea that you can sue Gavin King for inventing something better than Cocobase. But it’s true that Clark Kent invented the Wiki.

  38. fx Says:

    Dude, last year is over, we don’t talk about “impersonation” anymore.

  39. bleh Says:

    about frickin’ time JUnit got biled…what a joke. it’ll test the fsck out of your awesome StringUtil class, but other than that it’s obviously naff.

  40. real programmer Says:

    real programmers don’t write tests. Period.
    Don’t be a wimp, raise your head and face the act of development without a crutch.

  41. impersonated folk Says:

    may I remind you that “impersonation” and “impersonate” are trademarks of the JBozo Group Inc. – The joke^H^H^H^H server for the new age

    If you insist on using those words our impersonated lawyer will prosecute you.

  42. van Says:

    Leave your ammo for Mr.Bush.

  43. Lee Port Says:

    Fucknuts the lot of ya … I KNOW my code works so why do I have to write tests to show everyone else ?

    Just make sure you bow you heads reverentially as I walk past you serfs

  44. Trejkaz Xaoza Says:

    IMO, the only time unit testing works is when someone else writes the tests.

    So why is it that us developers are forced to write unit tests for ourselves? Wouldn’t that defeat the purpose, by using one block of flawed code to test another block of similarly flawed code?

  45. Anonymous Says:

    I agree, SUPPORT INDIVIDUALS ON THE JCP. We need more balance with the corporations. VOTE HANI!

  46. Scott McNealy Says:

    It really is James…

  47. Davide Inglima - limaCAT Says:

    First post on the JBoss vs Geronimo bile!

  48. anonymouse Says:

    If the BILE is BROWN,
    then you should punch a CLOWN

  49. anonymouse Says:

    JSR 69

    Java Porn API

  50. Fred Says:

    Thanks Hani, for such a wonderful article. I am going to donate my testing tool to commons project. You just watch, it will be elevated above JUnit in a short few weeks. I’ve had great successes using my personal commons-unit with my JBoss EJB 4.0 projects with JSF and integrating with Maven and Drools is a snatch. You can even configure it in XML or Ruby scripts and it’s great with dot NET. :) BTW, my daddy is also a leading cult expert. http://www.rickross.com

  51. Muhaha! Says:

    LOL, seems like Hani lost big-time to the G-Mail wankers and JBoss turdarians. Sorry, Hani, but why did you run for the election anyway? It seems like the only reason was to offer the Flurries a chance to look down on you for a change…

    Man, I’m dissappointed of you! Hope you at least had some “Oral” action with the gentleman who finished last.

  52. A Proud Black Man Says:

    What was that about “niggers” and Junit?

    Given that members of a national football team (soccer) Englandr were racially abuse last Wednesday
    I am surprised by your comments. I though software
    professional were above and aloof cultural hoo haas and demonstrated a better way to live
    your life on planet, Earth. I think some
    dont give a fuck whatever happens to progress
    so it will be the same as it ever was…

    The nuclear boob will prabably kill off all
    of us in the end, sunce as a human
    race were all fucked up.

    Well listen up to tjhis:

    Fuck you too, Hani you little bitch-ass cunt

  53. A Weak White Woman Says:

    “A Proud Black Man”
    A.k.a. Peter Pilgrim.

  54. Anonymous Says:

    Unit testing facilitates re-factoring you dumb ass. Junit or not, writing tests for every method is a must.

  55. James Says:

    On my way home from my paid software development job, every evening I pass a group of youths squatting on the cobbles in a circle next to the local mall. They sit there, dressed in their genuine imitation leather long black coats, jacked-up boots with big silver buckles, long, lanky black hair and heavy eye-makeup and bitch about everyone that walks past. “Look at that guy in the suit – he’s such a wage slave”. “Look at the good little housewife getting dinner for her husband”. “God, the cool kids at school are such losers”. “I’m glad I’m not a conformist like everyone else, I’ll never be a lemming” as they sit there in their identical clothes with their identical badges listening to identical goth music on their identical mp3 players and bum-puffing identical 1mg cigarettes with identical sneers absorbing their identical opinions from each other.
    Fast forward a few years…
    “God, those JUnit bible-thumpers are such losers, we’re so avant-garde in our disdain…”
    I hope this site is clever satire. I really do.

  56. dave morrison Says:

    yes, james gosling would say the word ‘fuck’ and yes, he is an asshole. believe me, i know

  57. dave morrison Says:

    oh, and btw-he hates being called jimmy

  58. dave morrison Says:

    James is not an asshole. I spoke too soon. I apologize.

  59. tom bombadyll Says:

    Before Junit, a company called parasoft.com used to call us every friggin day. They wanted to sell unit test frameworks. At least junit is free.

  60. Croctech Says:

    [Trackback] The Bileblog has a few words to say about blind adherence to the principles of testing with JUnit.

    It’s fairly impressive how unit testing seems to have grabbed a number of java developers by the balls, and made them sing in surprisingly high voic…

  61. katie goose Says:

    To “Dude”-whoever you are, I’m not into writing code, so I don’t usually visit these sorts of message boards, and if it’s an inside joke I would not understand it, but you don’t know Mrs. Gosling, and you have no right to call her a “whore”, because she is a perfectly respectable lady. If you feel it’s ok to just randomly insult other people’s mothers (or paternal grandmothers) there is something seriously wrong with you. While you may be annoyed some other Birkenstock and t-shirt wearing nerd, leave his mother alone!

  62. Test-driven-donut puncher Says:

    It should be renamed to gay-unit…

  63. test-driven-donut puncher killer Says:

    Shut the fuck up u cunt fucking breeding mother fucking “straight” bastard go rape a dyke normal you piece of fucking worthless shit. Fucking faggot!!!!!!!!!!!!

  64. katie goose Says:

    what’s up with nerds and profanity? learn something more interesting. try to elevate your vocabulary above the level of using a form of ‘f-ck’ to describe everything-or is that too f-ing hard?

  65. George Brooke Says:

    Hi,
    well that was a bit of a rant. My take on Junit is that it is somewhere between very useful and essential. Let me skip the obvious bit about unit testing and so on. I found in my work another use of Junit, but a rather indirect use. Essentially it boiled down to this: If I write code which is functional and at the same time ECONOMICALLY testable in JUnit then generally I have found the code under test to be well structured. Conversely, code which is hard to drive via JUnit has tended to need some re-engineering. If you like, putting a JUnit view on the code lets me see faults in structure (or more typically in functionality and encapsulation). I put this down to the constraint of the code needing to run in two environments (the JUnit and production environments). Code which I recently re-engineered to be easily movable between JUnit and the production system was much cleaner and better structured than previously.
    So, turning this all around. Let’s use Junit also as a tool to look at the structuring of our software. If the cost of JUnitting a piece of code appears high then perhaps the code needs a rewrite. Pair-wise development should make this easier as the correctiosn can be made on the fly.

    Just to avoid the explosion which might result from this, let me say that I believe that there are code constructions which are exceptions and which are inherently difficult to Junit, but let’s regard these as exceptions, and start to apply the “Economical Junit” test as a measure of quality.

  66. huanghaiymr Says:

    when a beginner code a simple code,code one,pass one,then code another,pass another,you insure your code is passed by yourself,so others can use your interface,so whole team’s code can pass.
    I can not imagining,Tom write 10 Class , include 100 method, everyone all not test, Jack also, in finally,Whole team could depend one Junit to test ,maybe 100 Class,1000 method, even more.
    I come from china, hello friends.

Leave a Reply