Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

Why We Refactored JUnit

Hemos posted more than 11 years ago | from the because-you're-maschoists dept.

Java 192

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."

cancel ×

192 comments

Sorry! There are no comments related to the filter you selected.

IN SOVIET RUSSIA... (-1, Troll)

Joey Patterson (547891) | more than 11 years ago | (#5172004)

JUnit refactors YOU!!! FP!

FIRST REPLY TO FIRST POST (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172681)

"YOU DID IT!" eats my jockeysmeg.

In Soviet Russia... (-1, Funny)

-1bynextweek (642604) | more than 11 years ago | (#5172011)

THIS doesn't have the slightest idea what YOU'RE about!!!

Re:In Soviet Russia... (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172091)

Man, you just can't get to terrible karma. I think you missed your next week limit. Tough luck.

Good news (-1, Troll)

faeryman (191366) | more than 11 years ago | (#5172019)

Excellent news that its finally out!

I've been having problems with JUnit before at my job and I hope this will really make my life a bit saner. I read the CHANGELOG and it looks like it addresses many of the issues I've been having and suggested to the authors to fix...ranging from some API libraries core dumping with signal NP-17 for no reason I can tell, it flooding our network with some wierd ICMP garbage to 209.242.124.241, and just being an all around bear to work with.

The coders are some nice guys. They let me have some early source diffs before getting this release out of the door. I used to get called in at least twice a week to help a network engineer get Artima back up and running, and it looks like this time around it will be /much/ more stabler.

This just shows the power of Open Source guys! I would like to have seen Micro$oft respond to my bug reports so quickly and actually fix them.

Re:Good news (2)

jovlinger (55075) | more than 11 years ago | (#5172138)

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)?

Isn't it obvious? (-1, Offtopic)

arcadum (528303) | more than 11 years ago | (#5172197)

YOU HAVE BEEN TROLLED.

Re:Isn't it obvious? (0, Offtopic)

obsidian head (568045) | more than 11 years ago | (#5172403)

Funny how the insightful comment was moderated down.

Re:Isn't it obvious? (-1)

Anonymous Coward | more than 11 years ago | (#5172496)

Funny how the insightful comment was moderated down.

Agreed. Please fix this moderators.

While your at it, why was the troll was modded to +5?

Actually this article seems to be attracting a crapflood of trolls....somethings up...a troll virus?

But.. (0, Funny)

Anonymous Coward | more than 11 years ago | (#5172140)

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

Re:Good news (-1, Flamebait)

tshak (173364) | more than 11 years ago | (#5172393)

This just shows the power of Open Source guys! I would like to have seen Micro$oft respond to my bug reports so quickly and actually fix them.


I'm not trying to troll, but with MS the bugs wouldn't be there in the first place. Seriously, when it comes to .NET, you can't use the typical anti-MS arguments. With some of the minor issues regarding .NET, MS have been reasonably quick to release updates, although again, the issues have been extremely minor.

Re:Good news (0, Redundant)

topologist (644470) | more than 11 years ago | (#5172470)

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).

HELLO. (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5172020)

My name is dingle. Pleased to meet you. Man, this "Slashdot" site sure does suck!

I wish... (5, Funny)

Anonymous Coward | more than 11 years ago | (#5172026)

I could refactor my unit.

Re:I wish... (5, Funny)

Forgotten (225254) | more than 11 years ago | (#5172085)

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

In Soviet Russia... (-1, Troll)

-1bynextweek (642604) | more than 11 years ago | (#5172115)

YOU refactor your unit for Lorena Bobbitsky!!!

Re:I wish... (2, Funny)

Flamerule (467257) | more than 11 years ago | (#5172129)

Hmmm.... You could refactor prime numbers [vill.edu] , instead....

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

Re:I wish... (0)

Anonymous Coward | more than 11 years ago | (#5172312)

So does your mom.

hrm.... (5, Funny)

xao gypsie (641755) | more than 11 years ago | (#5172030)

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

If only... (0, Offtopic)

Dougthebug (625695) | more than 11 years ago | (#5172046)

"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...

Re:If only... (0)

Anonymous Coward | more than 11 years ago | (#5172066)

It's called linux!!!!

ReactOS (2, Informative)

rfmobile (531603) | more than 11 years ago | (#5172077)

They are ... see ReactOS [reactos.com]

That is called wine (0)

Anonymous Coward | more than 11 years ago | (#5172104)

and it works pretty durn well too nowadays...

And meanwhile, In Soviet Russia... (-1, Offtopic)

-1bynextweek (642604) | more than 11 years ago | (#5172047)

non-trollable stories dislike YOU!!!

Re:And meanwhile, In Soviet Russia... (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172453)

disliked stories troll YOU!!!

genericity in testing (4, Interesting)

Anonymous Coward | more than 11 years ago | (#5172057)

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.

Re:genericity in testing (5, Interesting)

Anonymous Coward | more than 11 years ago | (#5172094)

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.

Re:genericity in testing (1)

xactoguy (555443) | more than 11 years ago | (#5172462)

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

Re:genericity in testing (5, Insightful)

Anonymous Coward | more than 11 years ago | (#5172660)

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.

Re:genericity in testing (1, Insightful)

Anonymous Coward | more than 11 years ago | (#5172853)

The sun is warm; the grass is green.

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

Re:genericity in testing (1, Informative)

Anonymous Coward | more than 11 years ago | (#5172154)

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

Re:genericity in testing (1)

dubl-u (51156) | more than 11 years ago | (#5172268)

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.

Re:genericity in testing (0)

Anonymous Coward | more than 11 years ago | (#5172599)

What the hell are you talking about?

ftp://ftp.kde.org/pub/kde/stable/3.1/src/ (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172064)

Leech now

ftp://ftp.kde.org/pub/kde/stable/3.1/src/

3.1 is there, man

The truth about XP (5, Interesting)

tundog (445786) | more than 11 years ago | (#5172074)

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.

Re:The truth about XP (5, Insightful)

Anonymous Coward | more than 11 years ago | (#5172120)

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."

Re:The truth about XP (4, Insightful)

babbage (61057) | more than 11 years ago | (#5172429)

On the other hand, there's Fred Brooks' advice from The Mythical Man-Month [aw.com] : "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...

Re:The truth about XP (4, Insightful)

tupps (43964) | more than 11 years ago | (#5172464)

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.

Re:The truth about XP (1)

kubrick (27291) | more than 11 years ago | (#5172564)

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

Re:The truth about XP (3, Insightful)

WaKall (461142) | more than 11 years ago | (#5172905)

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.

Origins of XP (5, Interesting)

Anonymous Coward | more than 11 years ago | (#5172123)

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.

Re:Origins of XP (5, Insightful)

Anonymous Coward | more than 11 years ago | (#5172157)

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.

Design first, or refactor? Re:Origins of XP (5, Insightful)

2nesser (538763) | more than 11 years ago | (#5172506)

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.

Re:Design first, or refactor? Re:Origins of XP (4, Informative)

chromatic (9471) | more than 11 years ago | (#5172611)

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.

Re:Origins of XP (4, Informative)

Anonymous Coward | more than 11 years ago | (#5172391)

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.

Re:The truth about XP (1, Interesting)

Anonymous Coward | more than 11 years ago | (#5172127)

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.

Re:The truth about XP (2, Informative)

mgrant (96571) | more than 11 years ago | (#5172215)

The other guy was Erich Gamma [c2.com] , of Design Patterns fame.

Re:The truth about XP (4, Insightful)

dubl-u (51156) | more than 11 years ago | (#5172248)

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 [amazon.com] , 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.

Great - now rewrite Ant (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172076)

Ant's a friggin' hodge-podge of crap and random XML APIs.

Re:Great - now REFACTOR Ant (0)

Anonymous Coward | more than 11 years ago | (#5172167)

Get with the XP lingo!

IN SOVIET RUSSIA... (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5172078)

... a blood-spattered drunken clown, arms wrapped around a filthy toilet, cries as shit squirts out of his trousers into his clown shoes. He heaves violently, splashing an enormous load of steaming, viscious vomit into the bowl and onto the floor. Ropes of bloody drool and mucus hang from his mouth and nose, and he begins to laugh. Then he downloads some Ogg Vorbis files on a P2P file sharing network and it Could Cost Him A Bundle But Then Again, Only People Who Don't Understand The Ramifications Of The Ongoing Revolution In Digital Media Seem To Care.

Intuitive (5, Insightful)

nettarzan (161548) | more than 11 years ago | (#5172121)

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.

Re:Intuitive (0)

Anonymous Coward | more than 11 years ago | (#5172191)

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.

Re:Intuitive (3, Insightful)

dangermouse (2242) | more than 11 years ago | (#5172199)

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.

Re: Intuitive (5, Funny)

Black Parrot (19622) | more than 11 years ago | (#5172254)


> Recursion is intuitive but...

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

Re: Intuitive (1)

astrotek (132325) | more than 11 years ago | (#5172753)

its just a loop

just generalize it for the morons

Re:Intuitive (2, Insightful)

iabervon (1971) | more than 11 years ago | (#5172314)

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?

Re:Intuitive (4, Insightful)

dubl-u (51156) | more than 11 years ago | (#5172319)

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.

Re:Intuitive (0)

Anonymous Coward | more than 11 years ago | (#5172813)

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...

BUT DOES JUNIS IN AFGHANISTAN USE JUNIT? (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5172124)

I really want to know.

Re:BUT DOES JUNIS IN AFGHANISTAN USE JUNIT? (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5172151)

Yeah...man...I remember using that back in the day. The beta's were written on the Apple IIC, but then Junis got his Commodore 64 around the time 1.0 came out. It's a fine machine too....also has net access and downloads heaps of porn, like all good Afghani people.

Wonder if Junis ever got a printer like he wanted.

Spelling Nazi says, "It's spelled 'masochists!'" (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5172128)

not maschoists!

it's all about compatibility (4, Informative)

ledbetter (179623) | more than 11 years ago | (#5172133)

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!

Re:it's all about compatibility (0, Troll)

First_In_Hell (549585) | more than 11 years ago | (#5172217)

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.

Read the tests (2, Interesting)

Anonymous Coward | more than 11 years ago | (#5172135)

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.

Standard litmus test (1, Troll)

Amsterdam Vallon (639622) | more than 11 years ago | (#5172137)

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

I wonder what really went on behind the scenes here.

refactor == rewrite? (4, Interesting)

_|()|\| (159991) | more than 11 years ago | (#5172172)

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?

Re:refactor == rewrite? (1, Informative)

Anonymous Coward | more than 11 years ago | (#5172204)

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....

Re:refactor == rewrite? (2, Insightful)

dubl-u (51156) | more than 11 years ago | (#5172214)

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

Re:refactor == rewrite? (0)

Anonymous Coward | more than 11 years ago | (#5172375)

So, is Linux a "refactored" Unix?

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

Re:refactor == rewrite? (5, Interesting)

bvenners (550866) | more than 11 years ago | (#5172720)

I interviewed Martin Fowler, author of Refactoring, last year. In this interview [artima.com] 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 [junit.org] with SuiteRunner's JavaDoc [artima.com] . 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.

free registration required? (2, Interesting)

smd4985 (203677) | more than 11 years ago | (#5172179)

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.

Re:free registration required? (0)

Anonymous Coward | more than 11 years ago | (#5172232)

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

Re:free registration required? (2, Informative)

bvenners (550866) | more than 11 years ago | (#5172641)

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.

JUnit does have problems, but .... (3, Interesting)

shamir_k (222154) | more than 11 years ago | (#5172198)

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

Re:JUnit does have problems, but .... (0)

Anonymous Coward | more than 11 years ago | (#5172264)

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?

Re:JUnit does have problems, but .... (3, Interesting)

bvenners (550866) | more than 11 years ago | (#5172560)

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.

JUnit? (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5172201)

...whatever the fuck that is.

J J J J-UNIT!!!!

more off-topic anti-americanism. w00t. (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172212)

Question 1) Which country was the primary "sponsor" - in terms of weapons, training and funding - of Osama Bin Laden and his fighters during the 1980s?

Q2) Which country's spokesman saw "nothing objectionable" in the Taliban's seizure of power in Afghanistan in 1996?

Q3) Which country unilaterally withdrew from the Anti-Ballistic Missile (ABM) Treaty in December 2001?

Q4) Which country renounced the efforts to negotiate a verification process for the Biological Weapons Convention and brought an international conference on the matter to a halt in July 2001?

Q5) Which country unilaterally withdrew from the Kyoto treaty on global warming in March 2001?

Q6) Which country is the world's biggest polluter?

Q7) Which country prevented the United Nations from curbing the gun trade at a small arms conference in July 2001?

Q8) Which country is the world's largest exporter of arms?

Q9) Which country was responsible for a car bomb which killed 80 civilians in Beirut in 1985, in a botched assassination attempt, thereby making it the most lethal terrorist bombing in modern Middle East history?

Q10) Which country's illegal bombing of Libya in 1986 was described by the UN Legal Committee as a "classic case" of terrorism?

Q11) Aside from Somalia, which is the only other country in the world to have refused to ratify the UN Convention on the Rights of the Child?

Q12) Which is the only country in the West which still permits the execution of children (i.e. "persons under the age of 18")?

Q13) Which is the only G7 country to have refused to sign the 1997 Mine Ban Treaty, forbidding the use of landmines?

Q14) Aside from China, which is the only other nuclear power to have refused to ratify the Comprehensive Test Ban Treaty (CTBT)?

Q15) Which country rejected the order of the International Court of Justice (ICJ) to terminate its "unlawful use of force" against Nicaragua in 1986, and then vetoed a UN Security Council resolution calling on all states to observe international law?

Q16) Which is the only G7 country to have voted against the creation of the International Criminal Court (ICC) in 1998?

Q17) Which country refuses to hand over a variety of indicted war criminals, terrorists and mass murderers - all residing within its borders - to Cuba, Venezuela and Haiti?

Q18) Which country has provided approximately $100 billion in aid to a country [Israel] which has maintained a 34-year occupation of land in defiance of international law?

Q19) Which was the only other country to join with Israel in opposing a 1987 General Assembly resolution condemning international terrorism?

Q20) Which country refuses to fully pay its debts to the United Nations yet reserves its right to veto United Nations resolutions?

Q21) Which country only ratified the Convention on the Prevention of Genocide in 1988, forty years after its passage at the United Nations?

Q22) Which country was accused by a UN-sponsored truth commission of providing "direct and indirect support" for "acts of genocide" against the Mayan Indians in Guatemala during the 1980s?

Q23) Which country is the driving force behind the current economic embargo on Iraq - responsible for the death of over half a million Iraqi children and described by one of its own legislators as "genocide masquerading as policy"?

Q24) Which is the only country in the world to have dropped bombs on twenty other countries since 1945?

Q25) Which is the only country in the world to have used all three types of "weapons of mass destruction" (chemical, biological and nuclear)?

A: The United States of America.

ALL MODERATORS DIE (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172243)

puke in a sock for junis.

Terrorists (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172871)

Q. Which country is the only one to have been tried and found guilty of terrorism in the International Court?

A. The United States of America, who arrogantly dismissed the findings.

And they wonder why we've had a gutsful...

Brigadier General Says Israel Is The Problem (-1, Offtopic)

Anonymous Coward | more than 11 years ago | (#5172247)

By James J. David Retired Brigadier General [whitecivilrights.com]
From RePortersNoteBook.com
1-7-3

Note - James J. David is a retired Brigadier General and a graduate of the U.S. Army's Command and General Staff College, and the National Security Course, National Defense University, Washington, DC. He served as a Company Commander with the 101st Airborne Division in the Republic of Vietnam in 1969 and 1970 and also served nearly 3 years of Army active duty in and around the Middle East from 1967-1969.

Question: Which country alone in the Middle East has nuclear weapons? Answer: Israel.

Q: Which country in the Middle East refuses to sign the nuclear non-proliferation treaty and bars international inspections? Answer: Israel.

Q: Which country in the Middle East seized the sovereign territory of other nations by military force and continues to occupy it in defiance of United Nations Security Council resolutions? Answer: Israel.

Q: Which country in the Middle East routinely violates the international borders of another sovereign state with warplanes and artillery and naval gunfire? Answer: Israel.

Q: What American ally in the Middle East has for years sent assassins into other countries to kill its political enemies (a practice sometimes called exporting terrorism)? Answer: Israel.

Q: In which country in the Middle East have high-ranking military officers admitted publicly that unarmed prisoners of war were executed? Answer: Israel.

Q: What country in the Middle East refuses to prosecute its soldiers who have acknowledged executing prisoners of war? Answer: Israel.

Q: What country in the Middle East created 762,000 refugees and refuses to allow them to return to their homes, farms and businesses? Answer: Israel.

Q: What country in the Middle East refuses to pay compensation to people whose land, bank accounts and businesses it confiscated? Answer: Israel.

Q: In what country in the Middle East was a high-ranking United Nations diplomat assassinated? Answer: Israel.

Q: In what country in the Middle East did the man who ordered the assassination of a high-ranking U.N. diplomat become prime minister? Answer: Israel.

Q: What country in the Middle East blew up an American diplomatic facility in Egypt and attacked a U.S. ship, the USS Liberty, in international waters, killing 34 and wounding 171 American sailors? Answer: Israel.

Q: What country in the Middle East employed a spy, Jonathan Pollard, to steal classified documents and then gave some of them to the Soviet Union? Answer: Israel.

Q: What country at first denied any official connection to Pollard, then voted to make him a citizen and has continuously demanded that the American president grant Pollard a full pardon? Answer: Israel.

Q. What Middle East country allows American Jewish murderers to flee to its country to escape punishment in the United States and refuses to extradite them once in their custody? Answer: Israel

Q. What Middle East country preaches against hate yet builds a shrine and a memorial for a murderer who killed 29 Palestinians while they prayed in their Mosque. Answer: Israel

Q: What country on Planet Earth has the second most powerful lobby in the United States, according to a recent Fortune magazine survey of Washington insiders? Answer: Israel.

Q. Which country in the Middle East deliberately targeted a U.N. Refugee Camp in Qana, Lebanon and killed 103 innocent men, women, and especially children? Answer: Israel

Q: Which country in the Middle East is in defiance of 69 United Nations Security Council resolutions and has been protected from 29 more by U.S. vetoes? Answer: Israel.

Q. Which country in the Middle East receives more than one-third of all U.S. aid yet is the 16th richest country in the world? Answer: Israel

Q. Which country in the Middle East receives U.S. weapons for free and then sells the technology to the Republic of China even at the objections of the U.S.? Answer: Israel

Q. Which country in the Middle East routinely insults the American people by having its Prime Minister address the United States Congress and lecturing them like children on why they have no right to reduce foreign aid? Answer: Israel

Q. Which country in the Middle East had its Prime Minister announce to his staff not to worry about what the United States says because "We control America?" Answer: Israel

Q. What country in the Middle East was cited by Amnesty International for demolishing more than 4000 innocent Palestinian homes as a means of ethnic cleansing. Answer: Israel

Q. Which country in the Middle East has just recently used a weapon of mass destruction, a one-ton smart bomb, dropping it in the center of a highly populated area killing 15 civilians including 9 children? Answer: Israel

Q. Which country in the Middle East routinely kills young Palestinian children for no reason other than throwing stones at armored vehicles, bulldozers, or tanks? Answer: Israel

Q. Which country in the Middle East signed the Oslo Accords promising to halt any new Jewish Settlement construction, but instead, has built more than 270 new settlements since the signing? Answer: Israel

Q. Which country in the Middle East has assassinated more than 100 political officials of its opponent in the last 2 years while killing hundreds of civilians in the process, including dozens of children? Answer: Israel

Q.. Which country in the Middle East regularly violates the Geneva Convention by imposing collective punishment on entire towns, villages, and camps, for the acts of a few, and even goes as far as demolishing entire villages while people are still in their homes? Answer: Israel

Q: What country in the Middle East is the United States threatening to attack because of fear that it may be a threat to us and to our allies? Answer: Iraq

Click for more info.

Paradigm shift? (4, Insightful)

HisMother (413313) | more than 11 years ago | (#5172270)

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.

Re:Paradigm shift? (4, Interesting)

Osty (16825) | more than 11 years ago | (#5172355)

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.

Re:Paradigm shift? (5, Informative)

Mithrandir (3459) | more than 11 years ago | (#5172492)

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.

Re:Paradigm shift? (5, Insightful)

The Musician (65375) | more than 11 years ago | (#5172589)

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.

Troll (-1, Troll)

Anonymous Coward | more than 11 years ago | (#5172273)

This is not a troll.

This is what I like about Open Source Software (4, Insightful)

Anonymous Coward | more than 11 years ago | (#5172284)

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.

My Complaint with JUnit (0, Troll)

SlashdotComplainer (645387) | more than 11 years ago | (#5172286)

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.

I tried too.. (2, Interesting)

spludge (99050) | more than 11 years ago | (#5172289)

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?

Re:I tried too.. (4, Informative)

bvenners (550866) | more than 11 years ago | (#5172510)

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.

Re:I tried too.. (1)

spludge (99050) | more than 11 years ago | (#5172673)

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..

Re:I tried too.. (2, Informative)

bvenners (550866) | more than 11 years ago | (#5172765)

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.

They rewrote the *runners*, not the *framework* (4, Informative)

lurp (124527) | more than 11 years ago | (#5172318)

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 [sourceforge.net] of occasions [sourceforge.net] .

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.

Re:They rewrote the *runners*, not the *framework* (5, Informative)

bvenners (550866) | more than 11 years ago | (#5172463)

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.

Re:They rewrote the *runners*, not the *framework* (0)

Anonymous Coward | more than 11 years ago | (#5172585)

Key word: afterthought. Nicely done, mr peanut.

if it ain't broke.... (2, Insightful)

the-build-chicken (644253) | more than 11 years ago | (#5172433)

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.

What's the big deal? (3, Interesting)

melted (227442) | more than 11 years ago | (#5172581)

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?
*

Re:What's the big deal? (0)

Anonymous Coward | more than 11 years ago | (#5172811)

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

Umm... (0)

Anonymous Coward | more than 11 years ago | (#5172708)

What the hell is a maschoist? Some kind of hideous deformity?
Load More Comments
Slashdot Login

Need an Account?

Forgot your password?