Slashdot Mirror


Why We Refactored JUnit

Bill Venners writes "In this article, three programmers tell the story of how their frustration with JUnit's API led to the creation of Artima SuiteRunner, a free, open source test toolkit and JUnit runner. These programmers simply wanted to create a small add-on tool to JUnit, but found JUnit's design non-intuitive and API documention poor. After spending time reading through JUnit's source code and attempting to guess at the API contracts, they gave up and rewrote it."

192 comments

  1. I wish... by Anonymous Coward · · Score: 5, Funny

    I could refactor my unit.

    1. Re:I wish... by Forgotten · · Score: 5, Funny

      You could, if you'd just read your spam before deleting it.

    2. Re:I wish... by Flamerule · · Score: 2, Funny
      Hmmm.... You could refactor prime numbers, instead....

      Not as sexy, but... oh, fuck it. This post sucks ass.

    3. Re:I wish... by Anonymous Coward · · Score: 0

      So does your mom.

    4. Re:I wish... by jcast · · Score: 1

      Actually, it's very easy to factor prime numbers. Now, mind you, the algorithm has a pre-condition that the numbers actually are prime, but that's another matter.

      --
      There are reasons why democracy does not work nearly as well as capitalism.
      -- David D. Friedman
  2. hrm.... by xao+gypsie · · Score: 5, Funny

    why does this sound like something of the beginning of a fantasy story about programming: "in the beginning was Iluvitar, the master of the JU API........then melkor, wishing to expand it...."

    xao

    --


    xao
    http://TheHillforum.hopto.org
  3. If only... by Dougthebug · · Score: 0, Offtopic

    "After spending time reading through JUnit's source code and attempting to guess at the API contracts, they gave up and rewrote it."

    Now if someone would just do that for Windows we'd be in business...

    1. Re:If only... by Anonymous Coward · · Score: 0

      It's called linux!!!!

  4. genericity in testing by Anonymous Coward · · Score: 4, Interesting

    One of the biggest problems for a testing framework is fitting all the tests you need in it. Data types such as XML make it really, really difficult.

    For example, you have a class that generates an XML document and you want to test it. Which level do you run the tests at? Best to test all levels, of course. How then do you check the accuracy of intermediate results? The answer often is that you can't; the intermediate results are meaningless until you have the complete (or at least almost complete) infrastructure to interpret the data. But once you've run all that, it is very difficult to pinpoint the source of the problem.

    I'm glad that Artima SuiteRunner provides a way to handle all of that complexity and write unit tests that are complete but tractable. I just wish it worked with Perl, since I don't use Java anyway.

    1. Re:genericity in testing by Anonymous Coward · · Score: 5, Interesting
      Data types such as XML make it really, really difficult.

      My big challenges are (1) existing code that wasn't designed for unit testing, (2) testing with databases, (3) testing that involves user interaction and (4) testing that involves multi-tasking. I like unit testing, but it is hard to apply to every task.

    2. Re:genericity in testing by Anonymous Coward · · Score: 1, Informative

      It's called XMLUnit (Google it in 2 seconds). Works great.

    3. Re:genericity in testing by dubl-u · · Score: 1

      Which level do you run the tests at? Best to test all levels, of course. [...] But once you've run all that, it is very difficult to pinpoint the source of the problem.

      It sounds like your unit tests are too coarsely grained, possibly because your APIs are too monolithic. Try breaking things down some.

      Generally, I write a couple lines of test code and then a couple lines of production code to make it pass. Then I rarely have problems testing the things I want.

      Feel free to drop me a line if you have questions; I've done a lot of testing of XML and HTML.

    4. Re:genericity in testing by xactoguy · · Score: 1

      My biggest problem is writing code that works in the first place so that you can even test it ;)

      --


      And so we go, on with our lives
      We know the truth, but prefer lies
      Lies are simple, simple is bliss
    5. Re:genericity in testing by Anonymous Coward · · Score: 0

      What the hell are you talking about?

    6. Re:genericity in testing by Anonymous Coward · · Score: 5, Insightful
      My biggest problem is writing code that works in the first place so that you can even test it ;)

      Ah, you do not understand the zen of XP yet. First you write the test. Then you write the code. Then you correct the code so the test passes. The sun is warm; the grass is green.

    7. Re:genericity in testing by Anonymous Coward · · Score: 1, Insightful

      The sun is warm; the grass is green.

      But you, poor Grasshopper, do not truely understand Zen.

    8. Re:genericity in testing by Anonymous Coward · · Score: 0

      Um, thus the introduction of .NET, or more in-line with your 'levels' query, NUnit... M$ ownz again.

    9. Re:genericity in testing by thempstead · · Score: 5, Funny
      Then you correct the code so the test passes.

      nonono ... you correct the test so the code passes ...

    10. Re:genericity in testing by jgerman · · Score: 1

      (3) testing that involves user interaction and


      That's what Excpect is for.




      (2) testing with databases,


      Make sure there's static data that is used for regression testing changes



      (1) existing code that wasn't designed for unit testing,


      No such thing. IF it can't be unit tested, then it's really, really bad code. The like of which no one has seen before


      Unit Testing isn't the be all and end all, but these complaints don't make sense.

      --
      I'm the big fish in the big pond bitch.
    11. Re:genericity in testing by jazir1979 · · Score: 1

      > (2) testing with databases,
      >
      > > Make sure there's static data that is used for > > regression testing changes

      Testing against databases has been one of the largest headaches where I work. When you have many developers running tests at the same time, as well as continuous integration running the tests every hour, maintaining data consistency can be a real headache.

      In the end we opted for a seperate test instance that only continuous integration uses. This contains static data as you mentioned, but where possible it is still best to use the setUp() and tearDown() capabilities. We built a framework that would allow test developers to simply supply SQL scripts for the set-up and tear-down process.

      Developers are still left sharing a database for their tests, and to solve this we simply had to be careful to write tests that were independant of certain properties of the data (such as the number of records returned by a query), and to ensure that each test restores appropriate data in its tearDown sequence. Sometimes tests can still fail when two developers run at the same time, but it is more unlikely, and at least the database finishes in a consistent state.

      Phew!

      --
      What's your GCNSEQNO?
    12. Re:genericity in testing by khuber · · Score: 1
      Have you tried using mock objects? If that's not a familiar term, it just means you create some kind of stub object to test with instead of a real database. Depending on an infrastructure for unit testing can be a pain. Been there, done that, got the database is down t-shirt.

      -Kevin

    13. Re:genericity in testing by jazir1979 · · Score: 1

      It is interesting you should say that actually. I hadn't heard of them until about 6 months ago when one of the developers in our team started using them.

      But we used them primarily for obtaining objects from APIs which we depend on, but which did not exist or work yet.

      When you get down to it, the db-interaction has got to be thoroughly tested. It's great to have tools that get around this when possible, but nothing beats a full-fledged unit test going the full way through.

      As for the "database is down t-shirt"...i've got worse..narky e-mails from clueless management saying "why are our tests failling?". Ughh. Continuous integration is a fantastic idea, but u really need managers who understand that sometimes the tests are just gonna fall over!

      --
      What's your GCNSEQNO?
    14. Re:genericity in testing by Anonymous Coward · · Score: 0

      ... for the sun is cold and the grass is red.

      And the apprentice said, "so the grass is both green and red?"

      And the master said, "look at the grass, what do you see?"

      "Green grass."

      "Stupid apprentice!" The master said, and hit him on the head with his cane.

      "Red grass then?"

      "Stupid apprentice!" The master said, and hit him agian.

      And then the apprentice was enlightened.

    15. Re:genericity in testing by Mark+Leighton+Fisher · · Score: 1

      You need to work with Test::More, which provides a nice standard framework for unit testing in Perl. You may need to extend Test::More by deriving from Test::Builder (the underlying library) if you have more sophisticated test reporting requirements.

      --
      "Display some adaptability" -- Doug Shaftoe, _Cryptonomicon_
    16. Re:genericity in testing by Mike_R · · Score: 3, Informative

      Unit testing databases can be simplified by using DBUnit.
      With DBUnit, you can describe your database in xml, and each time the tests are run, dbunit creates a new test database starting from the xml files. So you always test on a clean database. Check it out!

    17. Re:genericity in testing by Spoing · · Score: 1
      Ah, you do not understand the zen of XP yet. First you write the test. Then you write the code. Then you correct the code so the test passes.

      That's extreme programming? Good thing I didn't spend time reading up on this new methodology since I've been doing that for 10+ years. Not for speed, mind you, just to make sure that delivery matches desire.

      --
      A firewall can not protect you from yourself. Turn off what you do not need. Do not use the firewall to do your work.
    18. Re:genericity in testing by Xthlc · · Score: 1

      My big challenges are (1) existing code that wasn't designed for unit testing, (2) testing with databases, (3) testing that involves user interaction and (4) testing that involves multi-tasking. I like unit testing, but it is hard to apply to every task.

      Unit testing is a limited tool that can be very useful for certain things. Some of its limitations can be overcome by spending time writing elaborate test fixtures, but many (like 3 and 4 above) cannot.

      I guess my point is -- don't be afraid to write stupid, obvious unit tests. The point of unit testing is that it allows you to make massive, frightening changes to your code -- and then ensure that, as far as the outside world is concerned, your module still behaves the same way.

      After I got some experience with it, I simply started thinking of it as just another tool in our test suite, along with the Robot-based GUI tests and more complex, human-assisted test code.

    19. Re:genericity in testing by Nyarly · · Score: 2, Insightful
      That's extreme programming? Good thing I didn't spend time reading up on this new methodology since I've been doing that for 10+ years.

      You'd probably love XP then. A lot of the XP methodologies (with the possible exception of Pair Programming) make heaps of sense, and it's extremely nice to have them all in one tidy package that you can sell to management.

      --
      IP is just rude.
      Is there any torture so subl
    20. Re:genericity in testing by KillerCow · · Score: 1

      >the intermediate results are meaningless until you have the complete (or at least almost complete) infrastructure to interpret the data

      If that is your case, then you are performing system testing and not unit testing. If intermediate results are meaningless but you want to test them, then you need to define what the intermediate result should be in your specification. That's what unit testing is: you test one unit of you code and say "if this unit works correctly, then it fulfills its design contract, and any other unit that uses its contract correctly will receive guaranteed results." If your intermediates are meaningless, then you can't say that, and you can't test individual units.

      Unit tests are great, I write them for every class (except pure view components -- they change too much to keep the tests current). Just exercise every public method on the class and make sure you have coverage. If you don't know what a result should be, rethink your spec. If you want to test a private method, refactor. Run your unit tests as regression tests. Consider them to test each individual component.

    21. Re:genericity in testing by Anonymous Coward · · Score: 0

      Boot to the head!

      No, grasshopper, you are confused again. It is the test that is all-knowing, and it is the code that must, with your help, learn how to pass the test.

    22. Re:genericity in testing by Kombat · · Score: 1
      No such thing [as code that wasn't designed to be unit tested]. IF it can't be unit tested, then it's really, really bad code. The like of which no one has seen before

      Well, that's a pretty gratuitous oversimplification. Obviously, you've never written a lick of code that has to deal with I/O, GUIs, or multi-threading. How exactly do you propose to unit test a low-level class that formats a drive? How about your GUI? What about a class that interacts with DNS's? Or hosts an FTP site? Are you going to create/delete a thousand files on your drive, just to do your test? Are you going to write up a bunch of dummy/proxy network clients to test your socket traffic?

      At some point, once you've gained a little coding experience, you'll learn that if you have to write more testing code than code being tested, than chances are your testing code has more bugs than the original code. You'll realize that there are some cases, albeit isolated ones, where the effort involved in writing unit tests for a particular component outweigh the potential time savings compared to testing it manually and leaving it alone.

      Intelligent, fine-grained class factorization can minimize the occurrence of these classes, but nevertheless, they'll come up eventually.

      --
      Like woodworking? Build your own picture frames.
    23. Re:genericity in testing by jgerman · · Score: 1
      Number one, I've been coding for over 15 years. I have plenty of experience. There is still no such thing as code that wasn't designed to be unit testing. Once YOU gain a little more experience, you'll realize that unit testing is about testing each subroutine as you write it. Yes there can be some difficulties with certain types of code, it can be nerve wracking adding unit testing after the fact, but it CAN be done.


      I've written plenty of code dealing with I/O, GUI's, and multi threading. And I'm smart enough to devise unit tests for all of those applications. Do I always use unit testing, no, is it possible to add unit testing to ANY code. Yeah it is. Talk to me when you've had a few more years under your belt.

      --
      I'm the big fish in the big pond bitch.
  5. The truth about XP by tundog · · Score: 5, Interesting

    I find this quite amusing. I recently attended a talk in Montreal given by Kent Beck, one of the X-programming icons. One of the key elements of XP, as I understood his talk, is cutting down what he calls excess 'inventory' which include things such as excess documentation, architecture, etc. By keeping these iventory elements to a minimum, you get quicker feedback, because you have quicker results, which feeds back into the process and allows you to respond quickly to changing requirments.

    Well, it also happens that JUnit was developed al la XP by Kent and one other guy (didn't pay attention to who, go look it up!) For a while I was thinking that this XP thing might actually be something, but after skimming through the first 5 chapeters of 'Planning XP' coupled with the statements concerning the JUnit API, I'm starting to think that XP really is just one big hot air balloon.

    In his defense though, he did say that refactoring often was a GOOD idea. It's just that he didn't say that you should wait for someone else to do it for you.

    My 2 cents.

    --
    All your base are belong to us!
    1. Re:The truth about XP by Anonymous Coward · · Score: 5, Insightful

      I'm surprised, it almost seems like you didn't read much of the information on the website... like you... maybe... just read the slashdot headline and then formed your opinion... because here's what they guy who re-wrote JUnit said:

      "at one point I just threw up my hands and said to myself, "Why is this so hard? It would be easier to rewrite JUnit than figure it out."

      Just some friendly advice: if you ever find yourself saying it would be easier to rewrite something rather than figure it out, slap yourself. Chances are you are wrong. I certainly was. Creating SuiteRunner was a huge amount of work. Despite my frustrations with JUnit, it would have been orders of magnitude easier to decipher JUnit's source code than to create a brand new testing toolkit."

    2. Re:The truth about XP by Anonymous Coward · · Score: 1, Interesting

      I don't think the Eclipse project (www.eclipse.org) is a "big hot air balloon". Oh BTW the other guy is in this project too. Take time to analyse what are you talking about before giving your 2 cents.

    3. Re:The truth about XP by mgrant · · Score: 2, Informative

      The other guy was Erich Gamma, of Design Patterns fame.

    4. Re:The truth about XP by dubl-u · · Score: 4, Insightful

      but after skimming through the first 5 chapeters of 'Planning XP'

      If you're a programmer, that's the wrong book to start with. Read Extreme Programming Installed, by Jeffries, et al.

      I'm starting to think that XP really is just one big hot air balloon.

      In my experience, it's not. Since adopting it a couple years back, my designs are better, my bug counts are much lower, and I am much happier. Feel free to drop me a line if you have questions.

    5. Re:The truth about XP by babbage · · Score: 4, Insightful
      On the other hand, there's Fred Brooks' advice from The Mythical Man-Month: "Plan to throw the first one away. You will anyhow."

      Sometimes, it really is easier to treat the first one as a prototype of what you'd really like, and then write that second one correctly, from scratch. Witness Mac Classic -> Mac OSX, Win9x -> WinNT, Perl5 -> Perl6, etc.

      A lot of these prominent "next-generation" systems may share ideas & even code from their predecessors, but the essential point with each is that they all represent deliberate jump-cuts from the past. Sometimes it really is easier and better to rewrite something, whether or not you fully grok the original.

      The real trick is to design systems well enough that, when someone comes along with better ideas, the framework you provide is robust enough to adapt. Mac Classic, Win9x/DOS, and Perl5 are all too inflexible for future use, though at this point each of them is still useful to certain groups. Their successors, however, are all designed with future expandability in mind, so that the "second system curse" can hopefully be avoided. History will tell if it ended up working in any of these cases...

    6. Re:The truth about XP by tupps · · Score: 4, Insightful

      I think comparing operating systems as a way of throwing out your first born is not correct. Eg MacOS Classic was a direct descendent of the original MacOS that launched in 1984. I am sure that there is very little or no code from the original. Win9X was built on top of DOS which I believe has a lineage older than MacOS classic. Interesting note that both MacOSX and WinNT both came from an external base (NeXT and OS2 sort of). If you want a better example IE 3.0 --> IE 4.0, Microsoft is a classic for working out the problems in the first version or two and then releasing a quality product.

      --
      Go out and get sailing!
    7. Re:The truth about XP by kubrick · · Score: 1

      Apparently Windows NT also owed a lot to Mica, Dave Cutler's next-generation VMS, which got canned by Digital.

      --
      deus does not exist but if he does
    8. Re:The truth about XP by WaKall · · Score: 3, Insightful

      If YOU write the first one, throw it away, and write the second one, then yes, you may be on to something. However, if someone else writes the first one, and you can't understand it/use it, it doesn't that the first solution wasn't good. Maybe the problem lies somewhere else?

      You don't learn as much from reading someone else's code as they did from writing it. Don't try mis-quote Brooks to justify not understanding an existing product. Brooks was referring to large-scale team oriented development (like the System 360, or IBM 650 probjects). He wasn't claiming that you should throw out someone else's code because it was the first solution to a problem.

    9. Re:The truth about XP by forgoil · · Score: 1

      Microsofts DirectX has shown similar characteristics where earlier versions simply had to be redone into much better, newer, versions.

    10. Re:The truth about XP by Ed+Avis · · Score: 1

      This brings to mind the most annoying thing you can say to a doctor:

      Physician, heal thyself!

      --
      -- Ed Avis ed@membled.com
    11. Re:The truth about XP by Ed+Avis · · Score: 1

      Actually I think perl5 was a rewrite and perl4 was thrown away. So they are throwing away two.

      But I think Brooks was talking about implementing the same specification, while perl5 is a much more powerful and grown-up language than perl4, and perl6 vs perl5 may turn out to be the same. So they are throwing away (or heavily modifying) the specification too, which is different.

      --
      -- Ed Avis ed@membled.com
    12. Re:The truth about XP by James+Lanfear · · Score: 1

      Sometimes, it really is easier to treat the first one as a prototype of what you'd really like, and then write that second one correctly, from scratch. Witness Mac Classic -> Mac OSX

      I can't imagine how MacOS Classic could be considered a prototype for OS X (read 'NEXTSTEP').

      Win9x -> WinNT

      WinNT is older than Win95.

      Perl5 -> Perl6

      I thought you said the second try was supposed to get it right ;-)

      Mac Classic, Win9x/DOS, and Perl5 are all too inflexible for future use

      MacOS I can see, and maybe DOS (it's amazing how much mileage people get out of that system), but Perl5? If Perl has ever had a problem, it's being too flexible in too many ways.

      Their successors, however, are all designed with future expandability in mind, so that the "second system curse" can hopefully be avoided.

      Of course that sort of expendability and flexibility may well be a second system effect itself.

      Planning for future is a good idea, but in practice you can't do it beyond certain bounds -- something totally unanticipated is going to come along and screw everything up sooner (I would say 'or later', but it never is). What you can do is shoot yourself in the foot trying too hard to accommodate every possibility. Better, I think, to accept that you'll have to throw away every design eventually, and plan accordingly.

    13. Re:The truth about XP by Anonymous Coward · · Score: 0
      The "other guy" was Erich Gamma - you may have remember him from such works as Design Patterns?

      All software sucks; some just sucks less that others.

    14. Re:The truth about XP by SurfTheWorld · · Score: 1

      While you certainly received a solid cornerstone of XP (keeping inventory low), there are other aspects of the methodology that are easy to implement, and produce magnitudes of fruit. I'm afraid you might not have fully absorbed the XP message: communication, simplicity, and testing are the key tennants (imo of course).

      A lot of people fall into the trap of relating the XP methodology to some familiar aspect of their current methodology. For example, a lot of my coworkers associate "stories" with "use cases" or "requirements". While use cases and requirements documents represent a subset of what a story represent, they fail to convey the communication and interaction with the customer essential to success. Moreover, stories are vehicles through which intent is transmitted between the customer and the programmer. I haven't been on a project yet where the customer wrote a use case, programmers disected it into small parts, estimated the effort required, handed it back to the customer, and asked the customer to define which use cases were the most important. More often than not, the customer does not even write the use cases, much less define which ones are to be implemented first. Often the programmers (or some manager associated with the development effort) write the use cases. And a lot of times, acceptance tests are not written to confirm the implementation of the use case. These concepts are all tangents around the XP methodology involving stories. Simply put, use cases are NOT the same as stories. XP Stories involve interaction, are estimated for time, are specified by the customer, are prioritized by the customer, and are verified by tests written by the customer. Use cases are just procedures.

      --
      Do it for da shorties
    15. Re:The truth about XP by Anonymous Coward · · Score: 0

      I'm not surprised that he found it easier to re-write his own testing framework instead of using JUnit. Just gotta admit there are smarter engineers that can rewrite something better from scratch than an existing piece of shit.

  6. ReactOS by rfmobile · · Score: 2, Informative

    They are ... see ReactOS

  7. That is called wine by Anonymous Coward · · Score: 0

    and it works pretty durn well too nowadays...

  8. Intuitive by nettarzan · · Score: 5, Insightful

    Is intuitive design necessarily good in programming.?
    Recursion is intuitive but not necessarily efficient in terms of performance.
    At what point do we decide which is better intuitive design or efficient design.

    1. Re:Intuitive by Anonymous Coward · · Score: 0
      Write clear code unless and until you've proven by profiling that your environment is too flawed to execute it efficiently enough. Premature optimization is the root of all evil.

      Efficient tail recursion is a Solved Problem. There's no reason to avoid it unless you can't use a decent optimizer.

    2. Re:Intuitive by dangermouse · · Score: 3, Insightful
      Recursion is not a design principle, it's an implementation decision-- like choosing between a switch block and cascading if/else blocks.

      The author of this article is talking about the JUnit API. An intuitive API is always a good thing.

    3. Re: Intuitive by Black+Parrot · · Score: 5, Funny


      > Recursion is intuitive but...

      You've obviously never tried to explain recursion to a group of average co-workers.

      --
      Sheesh, evil *and* a jerk. -- Jade
    4. Re:Intuitive by iabervon · · Score: 2, Insightful

      Intuitive deisgn of anything that people will need to change in the future is more important than anything else, because anything you do efficiently but confusingly now will get changed in the future to be broken. If a future programmer can understand your code easily, it can then be optimized if it turns out to be too slow. And good design often turned out to be both efficient and intuitive; it tends to be free of the junk that both makes things confusing and slow.

      For that matter, how fast do you want the testing infrastructure to run?

    5. Re:Intuitive by dubl-u · · Score: 4, Insightful
      Optimization should never be done until after you've run real-world use cases on code with a profiler. Until then, one should write code that clearly communicates its intent.
      "Premature optimization is the root of all evil."
      says Knuth, and Martin Fowler says
      "Any fool can write code that a computer can understand. Good programmers write code that humans can understand."
      Remember: Computers double in speed every 18 months, but programmers stay just the same. If we want our code to live a long and happy life, then clarity should almost always win over speed.
    6. Re: Intuitive by astrotek · · Score: 1

      its just a loop

      just generalize it for the morons

    7. Re:Intuitive by Anonymous Coward · · Score: 0

      This is all nice academia. Too bad tomorrow I'll have to get up and go back to the real world. Knuth and Fowler were not handed a project at 5pm tonight on an unknown platform and told to have it done by tomorrow...

    8. Re: Intuitive by WeeBull · · Score: 1

      If you have to/can't explain recursion to them, I pray to god they well BELOW average.

      That said, I feel your pain.

    9. Re:Intuitive by groomed · · Score: 1

      Bah, this is the kind of content-free catch-all argument that sounds good but ultimately wrecks more software projects than GOTOs and ineffective management put together.

      A program that lacks clarity isn't necessarily fast and a fast program does not necessarily lack clarity. What happens instead is that people tend to confuse clarity with abstraction. It's the abstractions that slow things down.

      If you want your code to live a long and happy live then your code has to provide value to the people who'll be using it. It has to be fast, featureful and bugfree. The Linux kernel, the Apache HTTP server, and the MPlayer movie player showed us that a pragmatic approach trumps any and all development orthodoxies.

      The Mozilla browser showed us something else.

      Worry about performance. Worry.

    10. Re:Intuitive by khuber · · Score: 1
      I find that a lot of low performing code is just shit code, not that it's overly abstract. And I'm not leaving myself out, I've written shit code once or twice.

      -Kevin

    11. Re:Intuitive by Anonymous Coward · · Score: 0

      Time to get a shotgun, or quit.

    12. Re:Intuitive by Khazunga · · Score: 1
      The Mozilla browser showed us something else.
      It showed us exactly what? It is more standards compliant than any other browser out there. Its fast enough. It runs on more platforms than any other browser out there. It took less time to write than its direct competitor (IE6 took over six years, Moz took less than five years).

      More than anything else, Mozilla's well thought architecture managed to build a WORA platform with a strategy different from Java's -- with better quality for desktop apps, I dare say.

      --
      If at first you don't succeed, skydiving is not for you
    13. Re:Intuitive by ManxStef · · Score: 1
      "Premature optimization is the root of all evil."
      Hey, that's what my ex-girlfriend said just before she dumped me!
      Oh wait, you said optimization...

      Thank you, thank you, I'm performing here all week - unless they find me and take me back to the asylum, that is *twitch*
    14. Re:Intuitive by Anonymous Coward · · Score: 0

      It says that you shouldn't optimize it before you have a solid proof that it's an actual bottleneck. Nothing less and nothing more. If it represents your whole design, you should better run perf tests early. And that's the whole point.

    15. Re:Intuitive by Webmonger · · Score: 1

      If Knuth had believed that the way you're making it look, he'd never have written The Art of Programming. What's the point of a better sort if you shouldn't optimize until you profile? "Oh, my profiler says this bubble-sort sucks. I guess I'll just recode it in assembly."?!?!? I don't think so.

      Premature optimization is a great evil, true. But it's just as bad to optimize too late. Before you even start programming, you need a language that will deliver the performance you need.

      As you're programming, design your program to be efficient. Don't write everything in assembly from the start, but avoid useage patterns that you know will be slow.

      Then, once it's written, you can profile. But you'll likely find it's easier to change the design than to speed up the existing design.

    16. Re:Intuitive by dubl-u · · Score: 1

      If Knuth had believed that the way you're making it look, he'd never have written The Art of Programming.

      Oh, please. Knuth is also a strong advocate of Literate Programming, the notion that code should be treated first as a piece of literature.

      There's nothing inconsistent here. Nobody, not me, not Knuth, not Fowler, is avocating stupid programming. Yes, you should be a master of algorithms, and yes, you should design so that later optimization is possible. But that shouldn't get in the way of writing clear, readable code except when you have the numbers to prove that performance is a real-world issue.

      And I will assert boldly that most of the optimization people do without profiling first is just a waste of money. I've never had to throw out inherited code just because it was too slow. Instead, the stuff I chuck is because it's too big a pain to work on.

    17. Re: Intuitive by Ian+Jefferies · · Score: 1
      You've obviously never tried to explain recursion to a group of average co-workers.

      1) Divide the group into two, sending one group into an empty room.

      2) Visit each room in turn, repeat step one until division is no longer possible (no axes, please!).

      3) Recombine in such a way that the entire group now understands recursion.

      Problem sorted.

      Ian.
      --
      A physicist is an atom's way of thinking about atoms
  9. Origins of XP by Anonymous Coward · · Score: 5, Interesting

    I'm sure you've also heard of a guy named Fowler... Martin Fowler is well known in the community for exactly two reasons.

    The primary one is his book Refactoring. It describes his experience as a consultant refactoring medium sized software projects, and gives a lot of advice on methods for refactoring.

    Apparently Fowler decided that refactoring is a good thing. Not just that, he decided that since refactoring is a good thing, and so should be the basis for programming, since most of the results of programming are bad. By that I mean just that most programs suck, not that they are evil or anything.

    At that point he joined forces with Beck and formed his second reason for being well known, XP. As far as I can tell, the philosophy of XP is, "Software usually ends up sucking and in need of refactoring after it has been extended too far. Why wait for it to be extended too far? Just make it suck in the first place and refactor all the time!"

    It does have a sort of perverse logic to it, but when I say that XP is bad, I don't just mean that it sucks. As well as sucking, XP really is evil.

    1. Re:Origins of XP by Anonymous Coward · · Score: 5, Insightful

      XP is about writing code that can easily be successfully refactored. Total-design-up-front bigots think the code "sucks" because the design wasn't much more general than actually needed at the time, not realizing that making a design at the start of the project that meets the requirements as of the end of the project is almost always impossible, and all the effort in doing so is going to be wasted.

    2. Re:Origins of XP by Anonymous Coward · · Score: 4, Informative

      At that point [Fowler] joined forces with Beck and formed his second reason for being well known, XP.

      Martin Fowler did not invent XP. It originated in the work of Ward Cunningham and Kent Beck, then was refined by Kent Beck with help from Ron Jeffries and other members of the original XP team. Martin Fowler is an active part of that community, so he co-authored one of the XP books.

    3. Re:Origins of XP by clyde7 · · Score: 3, Funny

      I agree. XP is like music in the ears of managers who handle projects and developers which already suck (BTW, Kent Beck is a consultant). XP is not meant to be applied by good developers.

      In order to write good (stable, maintainable, extendible, generic, efficient, ...) software efficiently, you want to minimize the overhead (tests, refactoring, redesign, debugging). This can only be achieved by good upfront design skills and applying them as early as possible.

      If the code is well written, there's few need
      for writing tests (except for sophisticated algorithms), almost no need for refactoring (except for really simple ones like moving/renaming), redesign or debugging.

      Unfortunately good OO design is a hard to learn skill and I haven't seen a good book on this yet.

    4. Re:Origins of XP by khuber · · Score: 1
      Insightful my ass! What fool modded this up?

      XP is not meant to be applied by good developers.

      If the code is well written, there's few need for writing tests

      Ha ha ha.

      -Kevin

    5. Re:Origins of XP by Ed+Avis · · Score: 4, Insightful

      If the code is well written, there's few need
      for writing tests (except for sophisticated
      algorithms)


      Well, duh. If it is well written it won't have bugs, by definition. But how do you find out whether the code is well written, except by thoroughly testing it?


      --
      -- Ed Avis ed@membled.com
    6. Re:Origins of XP by jorleif · · Score: 1

      I agree. XP is like music in the ears of managers who handle projects and developers which already suck (BTW, Kent Beck is a consultant). XP is not meant to be applied by good developers.

      It is quite interesting that you say this since a frequent criticism of XP is that it only works well for teams of good developers, who would presumably do pretty well using most methodologies. I can't see why managers would be so keen on XP either, since most managers would probably prefer methodologies which promise repeatable results.

      In order to write good (stable, maintainable, extendible, generic, efficient, ...) software efficiently, you want to minimize the overhead (tests, refactoring, redesign, debugging). This can only be achieved by good upfront design skills and applying them as early as possible.


      Oh, you call tests and refactoring overhead! Um, have you ever noticed that when a developer adds a feature to some software, or fixes a bug, there is a significant chance that he breaks the software. Therefore, if there are no tests in place he will have to test manually, which is a lot slower.

      If the code is well written, there's few need
      for writing tests (except for sophisticated algorithms), almost no need for refactoring (except for really simple ones like moving/renaming), redesign or debugging.


      Riiight, and if the system is actually useful the people who use it will want you to extend it. Or maybe they only use certain parts of it and want a more lightweight configuration with just some additional features. Or, maybe the system needs to be integrated with webservice X and legacy system Y. The point is that the designer, no matter how good he/she is, could possibly anticipate which one of these scenarios actually happened. Therefore either the design takes all of them into account, which means the system is incredibly bloated (not necessarily in execution but design-wise), or alternatively you will have to do redesign and/or refactoring. Both of these are a lot nicer to do if you have unit tests in place. That is why XP advocates unit tests and refactoring together.
      XP is not inherently anti-design. XP is geared towards application areas where requirements change frequently. Up-front design is therefore replaced with continuous redesign using refactoring. It should also be noted that other agile methodologies are not quite as radical as XP on this point, and they usually recommend a short up-front design period at the beginning of the project and/or iteration.

      Unfortunately good OO design is a hard to learn skill and I haven't seen a good book on this yet.

      Maybe Gamma et al. and Design Patterns could be a start.

    7. Re:Origins of XP by james_bray · · Score: 1

      "'m sure you've also heard of a guy named Fowler... Martin Fowler"

      Yeah, isnt he wanted for reckless-driving.

      Sorry, UK-joke. ;-)

      --
      http://www.reeb.freeserve.co.uk
    8. Re:Origins of XP by Anonymous Coward · · Score: 0

      XP is about making hack programmers look legit. XP has some good points, such as an emphasis on simplicity, testing, and customer satisfaction, but mostly it's about making bad habits look good, like no design and iterative feature hacking with ignorance to the bigger picture of the app.

      Some design up front is important. Documentation is important. Code ownership is important to an extent. In a medium to large system, having everyone able to change any line of code is just stupid. People change shit and don't have a clue why the code looks the way it does. One of the arguments for no code ownership is that a lead architect can't keep it all in his head. Well, what about a team of that consist of many folks that aren't as capable as that lead architect? they are able to comprehend the whole system according to XP. And, they are allowed to change whatever they want, when they want. So, get a couple of average programmers with large egos, and you have a lot of problems.

      I also read "Refactoring" by the same guy. It's great how we can create yet another term for "application support". But your just supposed to do it all the time instead of stabilizing an application. Whatever.

      XP is great for people who are happy doing bug fixes all day instead of avoiding the bugs to begin with. The assertion that XP results in less bugs is pure speculation and from my experience, a very misleading claim.

    9. Re:Origins of XP by clyde7 · · Score: 1

      It is quite interesting that you say this since a frequent criticism of XP is that it only works well for teams of good developers, who would presumably do pretty well using most methodologies. I can't see why managers would be so keen on XP either, since most managers would probably prefer methodologies which promise repeatable results.

      XP gives you deliverable for incremental steps. This kind of accountability (resulting in predictibility) is exactly what a manager wants.

      Oh, you call tests and refactoring overhead! Um, have you ever noticed that when a developer adds a feature to some software, or fixes a bug, there is a significant chance that he breaks the software. Therefore, if there are no tests in place he will have to test manually, which is a lot slower.

      They are overhead with respect to the actual code which is shipped and run. The tests are not part of the deliverable. I'm not against tests themselves. But bad code will require more testing until you find yourself comfortable with the code. Redesign is overhead as well. If you do it the TDD (test driven development - see new topic on /.) way, you will find yourself constantly doing refactoring. TDD consists of three steps: write a test, write hacky code to make the test pass, refactor and iterate over it. A lot of emphasis is put on writing tests and refactoring, which means that you will spend less time on writing actual code. If you're a bad developer, this is a great way to get concrete working results, but he/she will progress very slowly.

      Riiight, and if the system is actually useful the people who use it will want you to extend it. Or maybe they only use certain parts of it and want a more lightweight configuration with just some additional features. Or, maybe the system needs to be integrated with webservice X and legacy system Y. The point is that the designer, no matter how good he/she is, could possibly anticipate which one of these scenarios actually happened. Therefore either the design takes all of them into account, which means the system is incredibly bloated (not necessarily in execution but design-wise), or alternatively you will have to do redesign and/or refactoring. Both of these are a lot nicer to do if you have unit tests in place. That is why XP advocates unit tests and refactoring together.

      Well, good design is trying to do that. There are always requirements which you cannot anticipate. The challenge is to design software such that the cases of such requirements are minimized.

      XP is not inherently anti-design. XP is geared towards application areas where requirements change frequently. Up-front design is therefore replaced with continuous redesign using refactoring. It should also be noted that other agile methodologies are not quite as radical as XP on this point, and they usually recommend a short up-front design period at the beginning of the project and/or iteration.

      I agree with you that XP is meant for applications. But as soon as an application becomes bigger, what happens? It will be broken up into modules, libraries, layers, .. things which will justify an API. I'm not for upfront design of a whole system. It's just that I prefer designing ahead a little bit for each bit of feature which is added. In some way it's TDD in reverse order.

      Maybe Gamma et al. and Design Patterns could be a start.

      If good design was simply a matter of applying the right design pattern, that would be nice! Thinking in patterns helps, but I find only few concrete patterns in the book really important: Decorator/Proxy and Factory. There's one danger in using patterns as well: you end up reimplementing the same pattern over and over, resulting in redundancy and possible bugs. I like the idea of LOKI (Modern C++ Design by Alexandrescu) which uses C++ templates for implemnting patterns. All the specifics of a pattern are provided by policies, which the developer can write, but the pattern it self is written in code exactly once. That's really the level of reuse I'm striving for. Each concept ideally should be implemented only one time. Otherwise a system will be bloated with redundancy, which is bad design, which leads again to a lot of refactoring. Redundancy also leads to more bugs, since different code paths are taken (and might be untested) for essentially the same thing (more testing). I hope you understand now why I call refactoring and testing 'overhead'. They are mostly inevitable, but that doesn't mean that we have to spend most of time doing it. Writing code is really what we ultimately want.

    10. Re:Origins of XP by William+Tanksley · · Score: 1

      "his book Refactoring... describes his experience as a consultant refactoring medium sized software projects, and gives a lot of advice on methods for refactoring.

      That's not even close to an accurate description. Refactoring describes what R. is, why it's done, what you need in order to do it, and how to do some common types.

      At that point [Fowler] joined forces with Beck and formed his second reason for being well known, XP.

      Even more wrong. XP was developed from the conventions and experience of a lot of Smalltalk developers over quite some time. Fowler and Beck didn't invent or develop it; they came in after it was initially publicised.

      As far as I can tell, the philosophy of XP is, "Software usually ends up sucking and in need of refactoring after it has been extended too far. Why wait for it to be extended too far? Just make it suck in the first place and refactor all the time!"

      That's an interesting caricature, actually. There's more truth in it than in anything else you've said. XP does say that software usually ends up sucking because it's been extended too far without refactoring; so why wait for it to be extended too far? Refactor so it won't suck NOW.

      The conclusion you imply (that after the refactoring the code will suck worse) is blatantly wrong, of course -- but that's just a troll.

      Perhaps a better way of looking at XP is to observe that it tries to pull the software into maintenance mode as soon as possible, and make change as cheap as possible within maintenance mode.

      -Billy

    11. Re:Origins of XP by talleyrand · · Score: 1
      Well, duh. If it is well written it won't have bugs, by definition. But how do you find out whether the code is well written, except by thoroughly testing it?

      Yeah, you can even prove it is correct mathematically and still have errors.
      "Beware of bugs in the above code; I have only proved it correct."

      Don Knuth
      --

      "My fingers Emit sparks of fire in Expectation of my future labours." William Blake
  10. it's all about compatibility by ledbetter · · Score: 4, Informative

    Since until now JUnit really was the only game in town for java test-writing, I'm so impressed to see these guys put out something that's still compatible with it!! Even if it was frustration with JUnit that gave them the inspiration. All of us have a bunch of JUnit tests for our code (ok, well SOME of us do), and it's nice to have the option to try out another framework without having to refactor our tests.

    Really, in the world of open source, and free software way too little attention is paid to compatibility. Why not be compatible with your "competition"? It's not like you're competing for customers or market share, or any of that crap. We're all on the same team!

    1. Re:it's all about compatibility by First_In_Hell · · Score: 0, Troll

      You have no right to download "free" software. If you are going to leech of off the hard work of others then you are adding nothing to the community. Be a man and contribute something.

  11. Read the tests by Anonymous Coward · · Score: 2, Interesting

    Well, reading the source is good. But in XP the real "API documentation" are the tests for the system. If you can't understand the tests, you can't understand the program.

    Full disclosure: I haven't screwed with the JUnit internals. But I'm working on a system that has over a million lines of code and JUnit 3.7 works just fine for it. Thousands of tests, too.

  12. Standard litmus test by Amsterdam+Vallon · · Score: 1, Troll

    Explaining one's actions in a detailed and public manner is self-incriminating.

    I wonder what really went on behind the scenes here.

    --

    Reply or e-mail; don't vaguely moderate. Ex-O'Reilly/MIT employee, now a full-time Google employee.
  13. Re:Good news by jovlinger · · Score: 2

    Huh?

    *scratches head*

    JUnit is unit testing for Java, right? How does the JVM dumping core become the application's fault? How does network IO have ANYTHING to do with unit testing (unless you're testing a network app that is)?

  14. But.. by Anonymous Coward · · Score: 0, Funny

    my parents say I'm not old enough to look at core dumps rated NP-17.

  15. Re:Great - now REFACTOR Ant by Anonymous Coward · · Score: 0

    Get with the XP lingo!

  16. refactor == rewrite? by _|()|\| · · Score: 4, Interesting
    I'm the first to admit that I'm not buzz-word compliant, but I was surprised to read the following:
    [Artima SuiteRunner] is a design fork not a code fork, because we didn't reuse any JUnit code. We rethought and reworked JUnit's ideas, and wrote Artima SuiteRunner's code from scratch.
    I thought refactoring was massaging, even rewriting parts of existing code. So, is Linux a "refactored" Unix?
    1. Re:refactor == rewrite? by Anonymous Coward · · Score: 1, Informative

      Code refactoring is modifying code while preserving the same overall behavior; I suppose if you keep at it eventually all the original code will be gone. Design refactoring is presumably modifying design while preserving the same end results....

    2. Re:refactor == rewrite? by dubl-u · · Score: 2, Insightful

      Refactoring is improving the design of existing code. So yeah, they're just going for buzzword value here.

    3. Re:refactor == rewrite? by Anonymous Coward · · Score: 0
      So, is Linux a "refactored" Unix?

      A better question might be, "Is BSD a refactored SysV?"

    4. Re:refactor == rewrite? by bvenners · · Score: 5, Interesting

      I interviewed Martin Fowler, author of Refactoring, last year. In this interview I asked him to define refactoring. He said:

      Refactoring is making changes to a body of code in order to improve its internal structure, without changing its external behavior.

      We didn't refactor JUnit's code, because we didn't start with JUnit's code and make changes. But we did do what I consider a "refactor" of the design. We started in effect with JUnit's API, and made changes. We started with knowledge of what we liked and didn't like about JUnit's API, and refactored that.

      Where you can see the refactoring is not in the code, but in the JavaDoc. Compare JUnit's JavaDoc with SuiteRunner's JavaDoc. I'm guessing it was version 3.7 of JUnit that I had in front of me when I decided I would start over. It may have been 3.6.

  17. free registration required? by smd4985 · · Score: 2, Interesting

    i'd like to check out artima suiterunner, but i don't think one should have to register to get access to source. at the very least, we should be able to browse the source online.

    don't get me wrong - i'm happy the code is open. we use junit for our open-source product and anything that could help us better utilize junit is much appreciated.

    --
    smd4985
    1. Re:free registration required? by Anonymous Coward · · Score: 0

      Gah! Thankfully, their "Open Software License" allows redistribution without surveillance.

    2. Re:free registration required? by bvenners · · Score: 2, Informative

      It's Larry Rosen's Open Software License (OSL), not ours. I think it is a great license. I liked that they mention trademarks, for example. The main thing I didn't really like about it was the requirement that derivative works also be released under the OSL. I would have been OK with derivative works being proprietary. But I liked the OSL so much, compared to the many other existing open source licenses, that I went with the OSL.

      The reason I have people register is to capture email addresses of users. Even though SuiteRunner is free and open source, I consider it a product, and I want to be able to contact users. If you don't want to register, just go to sourceforge and look up the suiterunner project. You can download it there anonymously. Or if you register but don't want to be emailed ever, just uncheck the two newsletter checkboxes.

  18. JUnit does have problems, but .... by shamir_k · · Score: 3, Interesting

    I have recently begin to use JUnit and ran into problems right away with the classloading mechanism. If any of you have wierd problems with inheritance relationships breaking, try modifying the excluded.properties file inside the JUnit jar. This worked for me.That said, it would have been nice to be able to modify this without having to unjar anything.
    However, I wonder why they rewrote it from scratch. Wouldn't it have been simpler to redesign the problematic parts. And I also find it interesting that they have written their project to be compatible with existing tests. Does that means that JUnit's interface is not problematic, only the implementation? Seems to me like more of a case for JUnit 4.0 then a complete re-write from scratch.
    The follow up articles should be interesting

    1. Re:JUnit does have problems, but .... by Anonymous Coward · · Score: 0
      Of course it would have been simpler! What part of
      Just some friendly advice: if you ever find yourself saying it would be easier to rewrite something rather than figure it out, slap yourself. Chances are you are wrong. I certainly was.
      did you not understand?
    2. Re:JUnit does have problems, but .... by bvenners · · Score: 3, Interesting
      Well, let me clarify. It would have been far easier to figure out JUnit's source code, guess at its API contracts, and integrate my signature test tool with JUnit -- without touching any JUnit code.

      However, once I decided to "refactor" JUnit itself, I chose to not use any existing code. My main problem with JUnit was its API, not its implementation.

      This is really a generic issue: when do you tweak existing code and when do you start over? By nature I am highly suspicious of urges to start over. In this case, I wanted to redesign the API first and foremost. JUnit's existing code didn't offer much assistance there.

      On the other hand, JUnit's API design and very existence offered a huge amount of assistance. We could learn from what we deemed the mistakes in JUnit's design, and replicate what we felt were the good aspects of the design.

    3. Re:JUnit does have problems, but .... by shamir_k · · Score: 1

      I think there are 2 APIs discussed here. One is the standard test API consisting of TestCase, Test, etc. The other being the API for extending JUnit to support new functionality. I understand that you had problems with the latter, but not with the former? So you have rewritten it, while still supporting the standard test API. The idea being that people can reuse their existing suites, without having to rewrite them. Or have you rewritten both APIs, and also tacked on support for the "old" test API?
      What were the reasons for this decision? And is your tool now easily extensible?
      I still find it hard to believe that a total rewrite is really necessary. Not that I haven't advocated the same myself in more than one project for much shakier reasons :-D.

  19. Paradigm shift? by HisMother · · Score: 4, Insightful
    This is not a troll, but I'm struggling to try to understand why these guys had to work so hard to accomplish what they needed. By their own account, they were driven towards this because they wanted to write API conformance tests -- tests that pass if an API is implemented, regardless of whether it works or not. They wanted, I guess, to see a test pass for each API from the specification that was actually implemented, so they could compute a percentage.

    While I can understand what they wanted to do, I guess I don't see why they didn't do this the much easier and (to me, anyway) more obvious way: you write code that uses the API, and if it compiles, then the API is implemented. You write one tiny test class for each API. You have each JUnit test run a compiler over one single class, this proofing each API. This isn't exactly rocket science: you have a directory full of probe-class source code, a single method that tries the compile, and then any number of TestCases that each try to compile one class and pass if they succeed. This is hard?

    If you use the unpublished APIs to "javac," you could do this at lightning speed. Alternatively, you could just use a Java parser like the one that comes with ANTLR (since you don't actually need to generate any code) and do it even faster.

    --
    Cantankerous old coot since 1957.
    1. Re:Paradigm shift? by Osty · · Score: 4, Interesting

      And if the methods are there because they have to be to implement an interface, but they return some "Not Yet Implemented" error or exception? How do you handle that with your compiler? I agree with you that they could've accomplished their goal in a much simpler fashion (one test for each API that only fails if NYI is thrown, regardless of any other exceptions or error codes). However, that doesn't mean they shouldn't have re-written the software. They identified issues with extending the existing software, and if they had problems then surely plenty of other people are having problems as well. Assuming that they weren't on a schedule so tight as to prohibit it, they should then do the "right" thing and fix what's broken not only for their current use, but also for their future use and the use of others.

    2. Re:Paradigm shift? by Mithrandir · · Score: 5, Informative

      I am a spec writer, I don't play one on TV. I authored the EAI for VRML97 and the various programming APIs for X3D. These are ISO specs, so they come with a lot of weight behind them from the conformance perspective.

      As someone who is involved in specification writing of APIs I can tell you that a "compile test" is wholly insufficient for checking class/method signatures. (for this reply, I'm using method as being interchangable for any message passing system - C functions, Java methods, RPC calls whatever)

      The first and major problem is not that the methods exist - everyone can cut and paste the spec document - but ensuring that nothing else exists. The bane of every spec writer is the company/individual that decides that they don't like the spec and then proceeds to extend it with their own methods within the same class - often overloading existing method calls. It is these extensions that a spec writer dreads because the (often) clueless end user makes use of them and then wonders WTF their code won't run on another "conformant" implementations of that spec.

      Checking signatures is there for one thing and one thing only - making sure the implementors don't embrace and extend the specification in a way that is not permitted by the spec. Creating derived interfaces with new method signatures is fine, adding new method signatures to the specification-defined collection is not. A good conformance test suite will look at everything about the signatures to make sure everything is there, and nothing that should not be is not there.

      --
      Life is complete only for brief intervals in between toys or projects -- John Dalton
    3. Re:Paradigm shift? by The+Musician · · Score: 5, Insightful

      To help answer the grandparent's question: compile != matches API.

      Can you write a test-compile program that checks whether the proper public/private/proctected access modifier keywords are set up right on each method? That the method was specified for 'short foo' but the implementor used 'int foo'? Or like Mithrandir said, that no additional methods have been added (such as an overloaded version)?

      Basically, compile-compatability is not the same as using the precise APIs in the spec.

    4. Re: Paradigm shift? by Black+Parrot · · Score: 1


      > Can you write a test-compile program that checks whether the proper public/private/proctected access modifier keywords are set up right on each method? That the method was specified for 'short foo' but the implementor used 'int foo'? Or like Mithrandir said, that no additional methods have been added (such as an overloaded version)?

      Yes, and trivially easily. I code in Ada: all I have to do is try to compile the package.

      I don't even have to write a test program. The spec is part of the package's source code, and the compiler kicks sand in your face if the body doesn't conform to the spec.

      --
      Sheesh, evil *and* a jerk. -- Jade
    5. Re:Paradigm shift? by HisMother · · Score: 1

      >And if the methods are there because they have to be to implement an interface, but they return some "Not Yet Implemented" error or exception?
      If you read the article you'll see that for this part of the testing they don't care at all what the methods do, only that they're there. Other tests would confirm the functionality.
      But anyway, my original question was answered nicely by several of the respondents above: my scheme doesn't check for additions, only omissions, and furthermore in most languages it doesn't really check for signatures, either, especially return types.

      --
      Cantankerous old coot since 1957.
    6. Re:Paradigm shift? by Xthlc · · Score: 1

      > The first and major problem is not that the methods exist - everyone can cut and paste the spec document - but ensuring that nothing else exists.

      Understood. But then the question was why, in this particular instance, JUnit was insufficient for that purpose.

      I mean, its Java. You can use reflection to figure out everything you would need about a class, including any nonconformant methods it may have. Just build a collection of methods that ought to be in the API, get the collection that actually are in the API, and if there's any difference, fail.

      The article claimed that JUnit's assumptions about the classloader were incompatible with Jini. I can believe this -- I've encountered a lot of weirdnesses with JUnit's threading model (my most recent project involves a lot of asynchronous communication between peers). Really stupid things too -- like a test will run in a different thread when you fire off a batch of them, but if you run a single test it works in the AWT thread and can lock your GUI.

  20. This is what I like about Open Source Software by Anonymous Coward · · Score: 4, Insightful

    This is one reason I like OSS--when people are not satisfied with currently available solutions, they can take the code and improve it. I have not looked at the new code (and for that matter, am unfamiliar with JUnit), but I think allowing people the freedom to take code and improve it one of the best features of OSS.

    1. Re:This is what I like about Open Source Software by forgoil · · Score: 2

      That should be possible for people with unlimited spare time and huge bank accounts. For people with neither of those, or companies that needs to make money to pay their employees so that they can eat next month it is not true either. Having the code doesn't magically make things better.

      If I would have the choice between having or not having the source, I would go for having it. I wouldn't do much with it, execpt sending better bug reports, unless I was activly using it for development (as I work as a developer). But this doesn't change the quality of the binaries one bit.

      And the time it takes to rewrite a component is only reduced marginally by having the code for the component that failed you. Especially if it is very large. Let's go for some OSS examples.

      We've got Apache, and the company using it feels that it is failing them. The performace is just not good enough for them. They have the options to either rewrite, and this will take some quite considerable time, not to mention testing the server, writing plug-ins, etc. If they are not quite big they can't afford one, two, three developers working on this fulltime with no income for them. Developers don't come cheap, not by a longshot.

      The other option is to buy/switch to another server. It might be a free alternative (written in the most buzzwordy language of the day) or it might be ISS 6 coupled with Windows Server 2003. Either way it is much cheaper than a rewrite. Rewrites are very expensive.

      Open source is a good thing, and it surely can help in debugging and sending bug reports. Let's not get ahead of ourselves and say that it is bad. Many a time I have wanted the full source to windows to be able to find out what the heck is happening to my events, just to bring up one example.

      But, and this is a big but, opening the source doesn't make it better. And well written close source software will still be better than a badly written open source one. Just as buying software often is cheaper than building it yourself.

      The obvious exception is when software is written without monetary gains ofcourse. Be it that their employers help out, they live of other money (rich, student, won the lottery, begs for food), or similar. But then a big rewrite still costs time, which could have been spent differently.

      (But I must confess that I personally think that putting so much time into Mozilla when a rewrite (Konqi) took so much less time, is kind of insane. And any rewrite which makes it easier to develop software is a good timesaver)

    2. Re:This is what I like about Open Source Software by vrmlguy · · Score: 1
      forgoil (104808) said:
      We've got Apache, and the company using it feels that it is failing them. The performace is just not good enough for them. They have the options to either rewrite, and this will take some quite considerable time, not to mention testing the server, writing plug-ins, etc. If they are not quite big they can't afford one, two, three developers working on this fulltime with no income for them. Developers don't come cheap, not by a longshot.

      The other option is to buy/switch to another server. It might be a free alternative (written in the most buzzwordy language of the day) or it might be ISS 6 coupled with Windows Server 2003. Either way it is much cheaper than a rewrite. Rewrites are very expensive.

      You're making some assumptions there. First, that the costs of converting your existing codebase is less than the cost of finding and fixing the problem. If you're using a plug-in that isn't as well supported on the new server, then you could be trading one expensive rewrite for another (rewrite part of your server vs conveting all of your .PHP as .ASP). Second, that there are faster servers. Whether you're using Apache or IIS, you should first go to the appropriate news group and look for help. Taking the example of performance problems with Apache, you might find out that you should have multiple servers, some optimized for static content (i.e. images) and others for dynamic content.

      Open source tends to have better support via news groups because that's the only means of support. Yes, there are news groups for everything that MS makes, but many of the people buying those products tend to first go to published books and then consultants if/when they have a problem. The length of the publishing process guarantees that books will have incomplete or even misleading information, while consultants are frequently only as good as their last assignment is relevant.

      --
      Nothing for 6-digit uids?
    3. Re:This is what I like about Open Source Software by p3d0 · · Score: 1

      If there were a "-1: Obvious" moderation, I would have applied it to this post.

      --
      Patrick Doyle
      I mod down every jackass who puts his moderation policy in his sig. Oh, wait a sec....
    4. Re:This is what I like about Open Source Software by forgoil · · Score: 1

      Jupp, I made some assumptions to make my example work. There are ofcourse the options to try to fix the software, and in the case of something as well used as Apache there are certainly people interested in fixing it.

      But if nobody at Apache(etc) wants to fix it, you will have to do it yourself, and many small companies don't have the money to spend for that. My point wasn't that Apache somehow sucks or can't be fixed, only that having the source is no garantee for it being any good, or that it can be used to fix the problem at hand. I don't like that assumption.

      But as far as Apache goes, valid points.

  21. My Complaint with JUnit by SlashdotComplainer · · Score: 0, Troll

    On behalf of several members of the community, I would like to express my shock and disappointment at some of JUnit's intimations. Let's get down to business: It's easy enough to hate JUnit any day of the week on general principles. But now I'll tell you about some very specific things that JUnit is up to, things that ought to make a real JUnit-hater out of you. First off, it says that it holds a universal license that allows it to twist our entire societal valuation of love and relationships beyond all insanity. Yet it also wants to inspire a recrudescence of obnoxious fatuity. Am I the only one who sees the irony there? I ask, because I am aware that many people may object to the severity of my language. But is there no cause for severity? Naturally, I believe that there is, because there is a cost, a cost too high to calculate, for messing with the lives and livelihoods of thousands of people. I mean, think about it. Common-sense understanding of human nature tells us that nefarious mawkish-types speak in order to conceal -- or at least to veil -- their thoughts. Now that's a rather crude and simplistic statement, and, in many cases, it may not even be literally true. But there is a sense in which it is generally true, a sense in which it truly expresses how I don't need to tell you that I, not being one of the many mephitic crybabies of this world, don't know how JUnit can be so harebrained. That should be self-evident. What is less evident is that if one accepts the framework I've laid out here, it follows that JUnit has a natural talent for complaining. It can find any aspect of life and whine about it for hours upon hours.

    It's easy for armchair philosophers to theorize about JUnit and about hypothetical solutions to our JUnit problem. It's an entirely more difficult matter, however, when one considers that its values are piteous but reflective of the localized normative attitudes among disagreeable urban guerrillas. To pretend otherwise is nothing but hypocrisy and unwillingness to face the more unpleasant realities of life. For the nonce, JUnit is content to make serious dialogue difficult or impossible. But sometime soon, it will set the wolf to mind the sheep. Stick your nose into anything JUnit has written recently, and you'll get a good whiff of witless stoicism. JUnit says that it is a bearer and agent of the Creator's purpose. The inference is that the best way to make a point is with foaming-at-the-mouth rhetoric and letters filled primarily with exclamation points. I'm happy to report that I can't follow that logic. Anyway, that's it for this letter. Let JUnit read it and weep.

    --

    --
    kvetch, kvetch, kvetch

  22. I tried too.. by spludge · · Score: 2, Interesting
    I also spent many hours deciphering the complicated way that JUnit goes about things so that I could extend it to do what I wanted. In the end it turned out that I could do it (adding a method of timing only certain parts of each test in a generic way) relatively easily but it took many hours of head scratching to understand the framework. JUnit is very flexible, but the code is a bitch to understand :)

    Overall though it seems like mostly a documentation issue, not a design issue. Good documentation for the internals of JUnit is pretty non-existent from what I could find. I discovered a lot mostly from examining other JUnit extensions. With some good documentation on JUnit internals and documentation on the internal flow of operations I think I could have hugely cut down on the time I needed to figure out where to plug in. I would be willing to take a crack at this documentation, but I am *definitely* not the best person to do it :) However if anyone else is interested I would be willing to give it a go?

    1. Re:I tried too.. by bvenners · · Score: 4, Informative

      I also found that JUnit's documentation was poor, but it wasn't just that. It didn't seem to be designed as a user-friendly API, where the user is a programmer trying to use it as an API. As I wrote in the article, I really liked using JUnit as an application, once I got it going. It was when I went in to integrate my signature test tool with JUnit as an API that I really ran into trouble. The API documentation was very sparse and frustrating. I started looking at the code, which was confusing not just because of poor documentation, but of non-intuitive (to me, anyway) organization.

      I was able to figure out what the code itself was doing, but then I was left guessing at what the contracts of the types and the methods were. When you decipher code, you understand one implementation of an interface, not the abstract contract of the interface. I got so mad at it that I opened IntelliJ and started writing my own testing toolkit. I thought it would be fairly easy, but I was wrong. I underestimated how much functionality JUnit actually has in it. And although I think we did come up with a much simpler public API, it took a lot of work to simplify it. So I ended up with more appreciation of all the work that went into JUnit.

      I suspect that a lot of JUnit's bulkiness comes from the fact that JUnit started with Java 1.0 or 1.1 and evolved over time in wide-spread public use. Because it was so popular, any design blemishes couldn't be erased in later releases. Eventually enough such blemishes accumlate and it makes sense to start over.

    2. Re:I tried too.. by spludge · · Score: 1

      Could you explain what you mean by "you understand one implementation of an interface, not the abstract contract of the interface"? I'm not sure what you are getting at there..

    3. Re:I tried too.. by bvenners · · Score: 2, Informative

      A contract for a method in an interface doesn't say what the method does, it draws a fence around the full range of possible things that method could do. So for example, Collection.add method has the contract:

      Ensures that this collection contains the specified element.

      That leaves room for an implementation class, such as HashSet, to reject objects passed to add that already exist in the set. The Collection.add contract is abstract. It draws a fence around the full range of legal behavior for the add method. HashSet.add is a concrete implementation that is like a single point inside the Collection.add fence.

      Imagine stumbling upon the code to HashSet.add without the benefit of the detailed contract-oriented API documentation of Collection.add. You want to implement an implementation of Collection.add in a different way, but all you know is the single point represented by the HashSet implementation. You have to guess where the fence is.

      That was the real trouble I had trying to integrate with JUnit as an API. I spent time attempting to decipher the JUnit source code and understood fairly well what it was doing. I made educated guesses at the contracts, but given the non-intuitive (to me) nature of the JUnit API, I wasn't confident in my guesses. I could have integrated my tool and tested it with JUnit 3.6 or 3.7, but had little faith that JUnit 3.8 would not prove my guesses wrong and break my tool.

    4. Re:I tried too.. by Pastis · · Score: 4, Insightful
      First, to answer somebody's else comment, the other guy who coded JUnit that nobody can't remember was Erich Gamma. If that name doesn't tell you anything, go back and read some books. It's impressive how the most important people 10 years ago can be forgotten so quickly. Makes you understand why Software is often called Software Craft.

      Open source software don't come up often with design documents. This one does. To those who say JUnit is hard to understand, go and read the Cook's tour. Then you'll understand everything. Things have changed a little bit but not that much. Of course if you are not familiar with Design Patterns, I recommend to read Design Patterns first. Yes that's by Erich Gamma and co also called the Gang of 4

      I see allready people coming and say design pattern is crap, and that's a proof. But before coming in and complaining, remember the lessons learned by the people who have worked longer than us in this industry. KISS(Keep It Simple...) and don't reinvent the wheel: I am pretty sure that the elegant design used in JUnit could have been refactored quickly to do what those guys wanted without having to rewrite everything from scratch.

      The author of this new test suite says it all:

      Creating SuiteRunner was a huge amount of work. Despite my frustrations with JUnit, it would have been orders of magnitude easier to decipher JUnit's source code than to create a brand new testing toolkit.
    5. Re:I tried too.. by khuber · · Score: 1
      The basic code is only about 1000 lines. It's actually extremely simple. What is confusing about it? I don't get why people find it difficult.

      -Kevin

    6. Re:I tried too.. by jeksmith · · Score: 1
      >I am pretty sure that the elegant design used in JUnit could have been refactored quickly to do what those guys wanted...

      I'm not so sure. I extended JUnit last year for our functional automated test system. While I agree that JUnit is understandable using Design Patterns, I found it tougher to extend than I originally expected. From the Conclusion of A Cook's Tour:
      "There is a high pattern "density" around TestCase, which is the key abstraction of JUnit. Designs with high pattern density are easier to use but harder to change."
  23. They rewrote the *runners*, not the *framework* by lurp · · Score: 4, Informative
    It would be more accurate to say that they rewrote the junit test runners and not the framework itself. JUnit's framework has an extremely simple and clean design, and really doesn't need any changing. The design of the runners, on the other hand really sucks, as Kent Beck has admitted on a couple of occasions.

    That said, I don't know if artima has really contributed anything new here. Your IDE likely has a JUnit test runner built into it already (IntelliJ, JBuilder, and NetBeans all do). Ant also already has decent junit test and report targets, which basically include all of the capabilities artima has implemented. Another stand alone test runner is probably not all that useful for day to day development.

    1. Re:They rewrote the *runners*, not the *framework* by bvenners · · Score: 5, Informative
      Actually, we rewrote JUnit's basic functionality. You can use SuiteRunner standalone to create and run unit and conformance tests. JUnit is not required.

      We made SuiteRunner a JUnit runner as an afterthought, when it dawned on us that no JUnit user would use SuiteRunner unless it added value to their existing JUnit test suites.

      One of the things we did originally was make "test" an abstract notion. Reporters can indicate a test is starting, succeeded, failed, or aborted. When it came time to turn SuiteRunner into a JUnit runner, we were able to just report JUnit test results as another kind of test. We felt the ease with which we could turn SuiteRunner into a JUnit runner was a validation of our abstract test notion.

    2. Re:They rewrote the *runners*, not the *framework* by Anonymous Coward · · Score: 0

      Key word: afterthought. Nicely done, mr peanut.

    3. Re:They rewrote the *runners*, not the *framework* by tungwaiyip · · Score: 1

      "Actually, we rewrote JUnit's basic functionality."

      Aha! You build a new framework because you are not happy with JUnit's "functionality". It true that JUnit's "functionality", mostly in the runner, is not super strong. I don't think they mean to provide anything more than a few basic runners. It is mean to be extended. I wrote my own runner that setup my environment, parse my own suite file and output HTML reports. I ask myself am I still using JUnit when I have built 50% of "functionality" myself? In the end the value of JUnit do not lie in their code, which is thankfully simple. It is the concept of building unit testing modules and do it as part of the development process that is really innovative. So whether one use JUnit's or SuiteRunner is not that important. It would be win for software engineering in any case!

      Wai Yip Tung

  24. Re:Isn't it obvious? by obsidian+head · · Score: 0, Offtopic

    Funny how the insightful comment was moderated down.

  25. if it ain't broke.... by the-build-chicken · · Score: 2, Insightful

    and also, I don't have to put my email in the database of a company that may or may not honour their privacy policy when times get tough, when I download junit. Maybe I'm a little jaded about open source sites that look flashy and require emails to download...burnt by the whole 'jive' from coolservlets.com fiasco (making lot's of cash are you now boys...remember, you can't buy back your dignity). The simple concepts are often the best, junit works great. I see no real advantage in this one.

    1. Re:if it ain't broke.... by bvenners · · Score: 3, Informative

      As I mentioned elsewhere in this topic, I ask for registration so that I know who the users are. Even though SuiteRunner is free and open source, I consider it a product. If you check the Artima Newsletter checkbox, you'll be notified of updates to SuiteRunner as well as new articles on Artima.com.

      Also, for several reasons we decided to create a web-based discussion forum for SuiteRunner user support rather than using a mailing list. The web forum (I fear this will add weight to your conspiracy theory, but the forum is based on Jive.) requires that you have an account, so by getting an account when you download SuiteRunner, you are ready to post to the SuiteRunner users forum.

      On top of that, shouldn't I get points for requiring such a minute amount of information to register? Many times I have been confronted with a long scrolling page full of edit boxes I'm required to fill in. At Artima.com, all I ask for is a name, which you can fake, a nickname, which you can make up, and an email address that I confirm. The name and nickname shows up on forum posts. If you watch a forum topic you get notified by email when someone posts a reply, which is why I confirm the email address even if you opt out of the newsletter.

      Interesting that you found the site "flashy." I was going for simple. If you look carefully, you'll see the site is primarily text with a bare minimum of graphics.

      Nevertheless, although I incorporated Artima Software a couple years ago, it is still just one person (me). So what you really need to ask yourself is not whether you trust a faceless corporation with your email address, but whether you trust me with it. I assure you I am very concerned about privacy.

    2. Re:if it ain't broke.... by the-build-chicken · · Score: 1

      I should have clarified, by flashy, I meant having a definitely 'commercial' feel to it rather than most os sites...that's just the take I got from it, hey, I've been wrong before...like I said, just my opinion on that one. You make a good rebutal, and, I hope that I am completely wrong...only time will tell I guess. I give you full rights to post a big "I told you so" in 12 months if this product is still completely open source.

  26. Re:Good news by topologist · · Score: 0, Redundant

    I'm not certain why the parent was moderated as "informative"..it's clearly just a bunch of superficially technical sentences strung together to make it look interesting, but it has nothing to do with JUnit. And what's a signal NP-17? (Null Pointer SIGUSR2? grin).

  27. Design first, or refactor? Re:Origins of XP by 2nesser · · Score: 5, Insightful

    making a design at the start of the project that meets the requirements as of the end of the project is almost always impossible

    I believe that this quote is true for commercial software. The word processors, email clients and web browsers in the world should not be designed at the beginning of a project. The cost of doing that far outweighs the benifits. But...

    When you are designing life critical applications (fly-by-wire, ABS, pacemaker, cancer radiation machine...etc) it is not acceptable to be redesigning while coding.

    If you cannot model the way a system must react at all times, under any input, then what makes you think that your software should be responsible for someones life.

    More and more software is being designed for life critical applications. If XP is being used to develop them, I'm worried. You cannot stumble onto 100% correct software. In a large system it takes a lot of money - an exponential curve, the last 3 bugs will likely take more money than the first 100 - time and a good design.

    1. Re:Design first, or refactor? Re:Origins of XP by chromatic · · Score: 4, Informative
      In a large system it takes a lot of money - an exponential curve, the last 3 bugs will likely take more money than the first 100 - time and a good design.

      That assumes that the rate of the cost of change rises over time. XP rejects that assumption, and the XP practices are designed to keep the rate of the cost of change consistent.

    2. Re:Design first, or refactor? Re:Origins of XP by grydholt · · Score: 1

      I have never used XP in real life, since most of the projects I have worked with have been either been waterfall or lacked an active customer input in the XP sense.

      However, I have read a few XP books. The authors normally stress that XP can not be applied to all kinds of projects. One such kind is certainly life critical applications.

      In 'Agile Software Development', Alistair Cockburn states that all agile methodlogies should be applied with extreme care if at all when it comes to life critical applications.

    3. Re:Design first, or refactor? Re:Origins of XP by 2nesser · · Score: 2, Interesting

      Here is an honest question, I know very little about XP, but how does it keep the rate of change consistent with all this "refactoring" going on?

      As your code base increases from cycle to cycle and more features are added to the system do you not end up spending most of your time "refactoring" your old code so that the new feature fits into the system?

    4. Re:Design first, or refactor? Re:Origins of XP by acroyear · · Score: 1
      Mission Critical software, such as for example, the Space Shuttle, falls under the Software Engineering banner, not so much the Software Development banner that is most of what's released commercially and internally.

      The rules for Software Engineering are to assume that things won't change (there's hardware involved that has to meet the same predesigned specifications that was supplied to the software vendors to integrate with), and that changes have to be approved at several levels before being applied.

      Its slow, messy, bureaucratic, and its the reason we haven't lost a Space Shuttle for a computer bug. Would that the Mars missions were so specific -- consider what happened when what could/should have been caught by a design and code review and unit and integration testing (usually required in software engineering as well as XP) in a simulator (a metric->english non-conversion).

      --
      "But remember, most lynch mobs aren't this nice." (H.Simpson)
      -- Joe
    5. Re:Design first, or refactor? Re:Origins of XP by chromatic · · Score: 2, Informative

      That's a good question. Several of the other XP practices work in your favor in that case.

      First, if you've been doing the simplest thing that could possibly work, your code is already pretty simple -- it doesn't have superfluous stuff to work around. Second, if you're testing continually, you have a safety net to notify you if you accidentally break the essential behavior. Third, if you've been refactoring continually, the code will be decoupled and much easier to change. Aggressive testing helps this too. Finally, if you're using the planning game to work on half-day features, you're dealing with manageable chunks of code that very rarely touch more than a couple of individual units.

      There are times when you have to schedule a couple of days for larger refactorings, but they're not common. If you have intelligent developers who keep up the good practices, the code ends up really clean, really easy to extend, and surprisingly well-designed.

    6. Re:Design first, or refactor? Re:Origins of XP by chromatic · · Score: 1

      Exactly. That's a case where XP doesn't provide a compelling benefit. Steve McBreen's Software Craftsmanship draws a sharp distinction between Software Engineering and what the rest of us do.

    7. Re:Design first, or refactor? Re:Origins of XP by acroyear · · Score: 1

      Come to think of it, that was where the inspiration for my post came from...decent book, though I failed utterly in convincing my bosses to triple my salary ;-)

      --
      "But remember, most lynch mobs aren't this nice." (H.Simpson)
      -- Joe
  28. What's the big deal? by melted · · Score: 3, Interesting

    Our QA people have developed their own framework for running tests in C#. It automatically discovers test cases via Reflection API, allows to group them into suites, run suites, generate reports, debug. It took 2 people 1.5 months to write it (while also dogfooding it to themselves and writing actual tests). No big fanfare, no buzzwords.

    "Refactoring" - holy fuck, where do you get such words?
    *

    1. Re:What's the big deal? by Anonymous Coward · · Score: 0

      "Refactoring" - only in the Java world, where over-engineering is the norm.

    2. Re:What's the big deal? by khuber · · Score: 1
      "Refactoring" - holy fuck, where do you get such words?

      Uh, modern OO principles/agile development/XP/Martin Fowler?

      -Kevin

    3. Re:What's the big deal? by cymantic · · Score: 1

      I thought the whole point of Unit Testing was to design your tests first. Then build your system to meet those tests.

      By automatically generating your tests based on your existing API, don't you just show that your API does what you programmed it too? Not necessarily what your design intended?

    4. Re:What's the big deal? by jorleif · · Score: 1

      The point of unit testing is to test the units of some software (classes in OO systems), as opposed to testing the system as a whole for instance. What you described was test-first development which uses unit tests.

      I think the original poster meant their software identifies test methods using reflection just like jUnit does, not that it generates tests from the actual code.

    5. Re:What's the big deal? by ggruschow · · Score: 1
      Our QA people have developed their own framework for running tests in C#. It automatically discovers test cases via Reflection API, allows to group them into suites, run suites, generate reports, debug. It took 2 people 1.5 months to write it (while also dogfooding it to themselves and writing actual tests). No big fanfare, no buzzwords.

      "Refactoring" - holy fuck, where do you get suck words?

      I get a lot of those words by actively thinking about what I'm doing, and making sure I keep current by actively researching the subject.

      Such actions could've saved your business 1.5 months and at least $10,000 (assuming the QA people are American). You might've wanted to go to google and type ".net unit testing framework". That would lead you to NUnit... which happens to be "a framework for running tests in C# (or any other .NET language). It automatically discovers test cases via Reflection API, allows to group them into suites, run suites, generate reports, debug." Plus, it's free, written, debugged, and supported by people your organization doesn't have to pay.

      It's interesting that you used the term "dogfooding", which I'd say is even less intuitive than "refactoring". I take it you relied on someone else to teach that term to you? You are aware that it's a word that Microsoft announces with much fanfare that they do?

    6. Re:What's the big deal? by Bazzargh · · Score: 1

      I'd say the big deal is your guys spent 3 man months on something they could have just downloaded. There are 4 .Net/C# frameworks on this list, and 7 on this one.

      The /. article describes Bill Venner's justification for writing his own; did your guys have a reason for what they did, or was it just "not invented here" syndrome?

      Another question is how you could spend as long as 3 months on this at all, xUnit isn't complicated...they've just pissed away roughly £15,000-£63,000 of your customers money (depending on if they were permies or conslutants).

  29. Umm... by Anonymous Coward · · Score: 0

    What the hell is a maschoist? Some kind of hideous deformity?

  30. I rewrote it too: by CoderByBirth · · Score: 0, Offtopic

    public class TheUltimateUnitTestingFramework {
    public static void assert(boolean b) throws Exception {
    if(!b)
    throw new Exception("assertion failed");
    }
    }
    I give it to you for free.
    Documentation isn't done yet, but I'm planning to spend the next year developing it.

  31. Solid Foundation For Software Refactoring by Bart+Du+Bois · · Score: 3, Insightful
    To get to know refactoring, I can refer to http://www.refactoring.com (by Martin Fowler).

    For those interested in the value of refactoring (whether it's merely a buzzword), I can refer to a research project of ours, at http://win-www.uia.ac.be/u/lore/refactoringProject

    By the way: since the article does not go into behaviour-preserving restructuring of JUnit, they shouldn't mention 'refactoring' in the title.

  32. What should we compare? by Bazzargh · · Score: 1

    The junit docs document not only the framework, but the samples, and several implementations of TestListeners - an apples and apples comparison would be with the junit.framework package.

    Focussing in on this, it looks like you've dropped the Assert class (presumably this is only for jdk1.4?). TestCase and TestSuite have been merged (seems sensible enough), and you've also provided a concrete Runner (no equivalent in the junit framework). This leaves the refactoring of TestResult etc into Report (roughly speaking).

    Can you explain the advantages of what you've done in that last bit? I don't see that refactoring as resolving the classloader issues you mention in the article - they'd be handled in Runner/TestListener implementation.

    Thanks,
    Baz

    1. Re:What should we compare? by bvenners · · Score: 1
      I'm planning on publishing a series of articles that delve into the differences between JUnit's and SuiteRunner's APIs. Since both are rather small APIs, I think most readers will be able to grasp the APIs enough to understand the design tradeoffs being discussed. One of the reasons I decided to go ahead and finish and release SuiteRunner was so I could use it to get discussion about design going in the Artima Forums. In short, though, you are about right. The apples to apples comparison would be between junit.framework plus all the runner packages and org.suiterunner.

      JUnit's TestCase, TestSuite, Test, and Assert ended up being collapsed into Suite. In the process we collapsed the dozens of assertThis assertThat methods into two verify methods.

      JUnit's TestResult corresponds to SuiteRunner's Reporter, but whereas TestResult is a class, Reporter is an interface. Different implementations of Reporter can report results in different ways. One implementation of Reporter we have internally holds multiple other Reporters and forwards reports to all of them. That allows you to combine multiple reporters in a single test run. You can kind of get at the same thing in JUnit by registering TestListeners with a TestResult.

      Anyway, I'll eventually go into details in a series of articles.

  33. Yet another JUnit like tool. by M.M.M. · · Score: 3, Informative

    I have another one,
    it is geared towards tests with multithreaded environment.

    here is the project page
    http://www.michaelmoser.org/jmtunit/

    The library sets up a thread pool (n threads) and runs a number of identical test sequences; each test sequence is a virtual user (m users). All threads are waiting on one input queue for test requests. The threading modell is the same as in most of the popular application servers

    The programming interface is very similar to JUnit - there is a JMTUnit.TestCase with some additions, there is JMTUnit.TestResult.
    The tool does print out performance statistics

  34. Re:Spelling Nazi says, "It's spelled 'masochists!' by Anonymous Coward · · Score: 0

    Sadist moderators.

  35. Not refactoring by Anonymous Coward · · Score: 0

    the API contracts, they gave up and rewrote it.



    If they rewrote the API then this is not refactoring. Refactoring is when you rewrite code without changing the external interface.

  36. Test-Driven Development by PinglePongle · · Score: 2, Informative

    Kent Beck - co-author of JUnit - recently published "Test-Driven Development", a book about how you can change your coding habits by creating the tests up front.

    One of the most useful sections is a complete walk-through of the creation of unit-testing tool for Python - it's probably the best way of understanding the internals of the JUnit framework without trying to reconstruct every single line of code...

    --
    It's all very well in practice, but it will never work in theory.
  37. Re: mod parent up by joss · · Score: 1

    'kin right.

    Superfluous layers of abstraction are the real enemy today. Too much flexibility, too many layers in the class library, not enough code that actually *does* stuff.

    Permature optimization is not the enemy any more. When Knuth complained about it most people wrote in assembly code and it was a concern. He was talking about things squeezing out an instruction by reusing the value in a register in a counter-intuitive way. Since OO became the dominant paradigm we have gone too far in other direction. The great thing about optimization is it causes people to focus back on what they are actually trying to achieve instead of concentrating on their over elaborate badly design class hierearchies.

    --
    http://rareformnewmedia.com/
  38. JUnit ClassLoader causes other problems too... by acroyear · · Score: 1
    Unfortunately, JUnit's graphical runner did not follow [JINI's] class loading model, and worked in a way that prevented class loading [...]

    I found the same problem when working with Ant and XML in JUnit, because the Ant system does its own class loader for the underlying XML parser, and my stuff got a LinkageError thrown when I tried to instantiate a parser, forcing me in a utility class to catch that error and call the good old fashioned "new" on the parser class within Xerces2.

    --
    "But remember, most lynch mobs aren't this nice." (H.Simpson)
    -- Joe
  39. outdated and naieve by dwk123 · · Score: 1

    Man, does this make my blood boil every time I read it. At best, it's outdated, at worst irresponsible. 'Back in the day' when implementations were typically close enough to the hardware that the 'fundamental cost of operations' was relatively well understood, this type of thinking wasn't unreasonable *at the code level*.

    However, when selecting base architectures, you have to think about performance *up front*, since you're not going to change the fundamental architecture at the end of the project with a few lines of tweaked code.

    Also, now that we have Java and OO and abstraction up the ying-yang, optimizing code is orders of magnitude more difficult in a real world project than it was when a project was a few 10k's of C code. Ever try 'refactoring' a significant API at the end of a project when you're already late?? Doesn't happen, and you ship something that runs like a dog.

    Truth is, you have to worry about performance right from the start. Performance and clarity are by no means incompatible when done properly.

  40. Re:Good news by Anonymous Coward · · Score: 0

    Why is this modded troll, seriously? The fact is .NET is genuinely a quality piece of software. Perhaps his use of "MS" in place of the more proper "M$" is what flagged it troll material.

    I hate to be a troll, but maybe you guys should put up a warning on the front page that people that use Microsoft products or think MS is anything short of the antichrist are not welcome - it would save those of us suckered in by that "News for Nerds. Stuff that matters." tagline some trouble.

  41. Some hints by alder · · Score: 1
    As I had to deal with all the challenges you've mentioned, I used to use some unit testing "patterns"/approaches that may be of some help:

    existing code

    In general that should not be an issue, as the code really expresses the function of the system and testing that function is somewhat orthogonal to the actual implementation. Obviously it makes life easier if you are able to create certain probing point inside the system, but even if that is not possible to do, you still can dissect it into manageable "units" that you will be able to test - the regular drill apply some input, check whether the output matches. Most of the time for the "foreign" code it's just an issue of finding proper point where to feed test data, and where to observe output. They are there, just have to be found

    databases

    More challenging, though still very possible. The easiest approach is to create a special schema just for testing. The main goal here is to have known data, i.e. to be sure that no other application changes them while test is running. It also helps that no one becomes upset about your test changing other peoples' view of the system state. One more trick is to write tests so that they restore database to the state it was before the test is run. And the last one - it is helpful to code an alternative data access methods, f.e. if youe object saves itself in the database, you check the result but reading it though "raw" JDBC.

    user interaction

    In general you are absolutly right - it's almost (maybe even totally) impossible task. Yet, again the right way is approach it is to split the "horizon", i.e. apply testing input to methods that normally accept UI inputs. In other words you'll have to create a "fake" implementation of your UI api, and make you code use it during testing, and that "fake" UI will feed the system with data. An example (not really GUI, but illustrates the concept): I had to test an object that parses HTTP requests and provides more convenient than HttpServletRequest and system specific services to the rest of the system. All I had to do is to create an implementation of HttpServletRequest that I populated with test data during test set up, and then feed to the object being tested my "fake" implementation. The same, maybe with a little more effort, can be done to emulate mouse clicks and movements, key presses, etc.

    multi-tasking

    No general answer unfortunately, at least not the one that can be applied everywhere. I used to "split the horizon" here too and to test extensively methods that run without cross-thread interaction, and minimize and encapsulate at the same time the code that serves as a cross-thread "bridge" and ... "test" it in my head many many times. Key part is making the code that let threads communicate really-really small, so that you can "run" it in your head.

    Hope that'll help, even if indirectly.

  42. What you say is true, grasshopper, ... by SimonK · · Score: 1

    ... but it is not the whole story. The rule against premature optimisation exists for a good reason: most programmers have terrible intuition about performance. The one thing you should do up-front is get the architecture - the distribution of code over machines, processes and loosely-coupled modules - right, so that it does not contain performance bottlenecks that will be impossible to get rid of later. Prototypes work well for this, as do small applications that are structurally similar to the one you want.

    After that, all performance optimisation should be left until you can profile the application. Bits of the result will undoubtedly suck and need to be rewritten, but I'll put money on most of them not being the ones you expected.

    This is where abstraction comes is. Abstractions are a very important aid to clarity, because they allow parts of the system to be considered in isolation from one another. To give a slightly practical example, a product I recently worked on used a variant of the banker's algorithm to avoid deadlocks. An odd choice, I know, but it was absolutely imperative that the system shouldn't dealock, and killing or restarting threads was unacceptable. The algorithm is complicated, and the original implementation took the simplest possible approach. When we profiled it, this turned out to be too slow, so I rewrote it, but because it was reasonably isolated from the rest of the system, I could do this without touching any other code.

    Good abstraction is not the enemy of performance. It is its friend. In good abstractions, the data and code that need to work together, live together, and are shaped to one another. Oddly enough, this is what you need for performant software, too. On top of that, good abstractions make code easier to change.

    What is the enemy of performance is bad abstraction. Which means too little or the right amount in the wrong place, just as much as too much. Aspects of Mozilla's design show signs of bad abstraction. In particular, it is hard to develop good abstractions for cross-platform UIs, and Mozilla's attempt is no exception. Using the HTML/XML renderer and JavaScript to implement the UI is a clear example of Bad Architecture, see paragraph 1, even if it is convenient. Similarly, the need for the elaborate modular design is debatable.

    The design of the Linux kernel, is in many ways an example of Good Abstraction. Although it isn't written in a language that particularly facilitates abstraction (it is an OS kernel, after all), the different components are reasonable separated out. There don't appear to be direct dependencies between the IDE driver and the memory allocator, for example.

  43. forking...bad! by stand · · Score: 1

    From the article...

    Just some friendly advice: if you ever find yourself saying it would be easier to rewrite something rather than figure it out, slap yourself. Chances are you are wrong. I certainly was. Creating SuiteRunner was a huge amount of work. Despite my frustrations with JUnit, it would have been orders of magnitude easier to decipher JUnit's source code than to create a brand new testing toolkit.

    Then why don't you spend some time integrating your code into the JUnit code base? The Open Source cause (or the XP cause or whatever) is not helped by having two implementations of the same concept. This is a self-serving article reads like a marketing piece designed to show how clever the authors are. I'm not falling for it.

    --
    Four fifths of all our troubles in this life would disappear if we would just sit down and keep still. -C. Coolidge
  44. And I wonder why .... by AndyMouse+GoHard · · Score: 1

    You didn't read the article! How did you get a score of 3? Picture this: I don't even read the topic of the post, so I can add a comment like "I wonder what this is about?"

    Come one Shamir.

    Bill

    --
    Upon seeing the box was too small, Schrodinger's Elephant breathed a sigh of relief.
  45. Multitude of XP books - book refactoring by otisg · · Score: 1

    Damn, this guy Kent Beck surely (and Martin Fowler, and Jeffries, etc.) surely can write a ton of books on the same topic.
    It is all really the same philosophy - XP and refactoring and TDD (Test Driven Development), and so on. There is a lot of overlap there, and all is (obviously arguably) just good advice for approach to software development.

    How many times can they repeat the same thing?
    It is all just refactoring of the same material, same philosophies.
    What's the big deal?

    At over $30 USD per book, plus all the invitations to give speaches, presenations, and so on, it's quite obvious to me why they are doing it.
    Isn't that a bit lame, though, at least for them?
    Doesn't it get boring?

    --
    Simpy
    1. Re:Multitude of XP books - book refactoring by otisg · · Score: 1

      Now if this was only a reply in the right thread, that would be cool.
      Cf. http://slashdot.org/article.pl?sid=03/01/27/163122 6

      --
      Simpy
  46. Just a Ccomment by Anonymous Coward · · Score: 0

    Suite! oops I mean Sweet.

  47. YOU'RE AN ASTROTURFER! by Anonymous Coward · · Score: 0

    the moderator could see this - its that simple.
    If you don't believe me check out some of tshak's other posts.... careful though he's sly, reasonable in some forums to gain the good-K but once the topic of the beast is raised... well its fake and green as far as the eyes can see

  48. Code generation of JUnit test cases by situ · · Score: 1

    Hi,

    I'd like to know the experiences of people with regard to automatic(?) code generation of JUnit test cases. I'm refering to projects which do not work the XP way, but still would like to have high % of unit testing (meaning, unit test code is done at the end), and to projects that need to deal with legacy code.

    Specifically,
    (a) What has been your experience with tools which auto-generate test cases that give a good % of code coverage when tested with code coverage tools, such as Clover?

    I've worked with
    - open source options mentioned in http://www.junit.org/news/extension/testcase_gener ation/index.htm, but these only generate the skeleton of the methods

    - JTest, which generates pre-determined values for primitives, and does nothing about Java value object classes, and expects the programmer to add in the "other" test cases - which in effect turns out to be a lot.

    I guess what I'm looking for is a tool that "understands" the code and generates unit test cases for all the branches and conditions in the code, in order to achieve maximum code coverage. Is there any such beast out there? :)

    (a1) Has anyone worked with TogetherJ/XPTest (http://www.extreme-java.de) for generating JUnit test cases? I didnt see too much of high-lighting on the TogetherSoft site on this one... What have been your experiences?

    (a2) On a related note, does anyone know of XMI-compatible JUnit generators, which would remove the dependency on the UML tool?

    (b) What has been your experience with mock objects? Have they been too cumbersome a process for the average project size (say, 100 classes, with 10 value object classes)?

    (c) Building functional test cases: I've heard of JFunc; what are the other options, and how do they compare?

    Thank you very much,
    situ