An Early Look at JUnit 4
An anonymous reader writes "Elliotte Harold, proclaimed 'obsessive code tester', took an early look at JUnit4 and shows how to best utilize the framework in your own projects. Many feel that this is one of the most important third-party Java libraries ever developed. It promises to simplify testing by exploiting Java 5's annotation feature to identify tests rather than relying on subclassing, reflection, and naming conventions."
That supported attributed programming years ago? Oh I know, NUnit is a port^H^H^H^Hripoff of JUnit so it doesn't count.
"Utilize" would be "use" if you were speaking plain English. And no, using the word "utilize" doesn't make you seem any smarter.
What continues to stun me about the "professional" developers out there is how few do Unit Testing even when it is so easy. People complain about jobs moving offshore and pressure on delivery and people not understanding how hard coding is... but they don't even Unit testing.
If you don't unit test then you aren't a software engineer, you are a typist who understands a programming language.
An Eye for an Eye will make the whole world blind - Gandhi
However, I see very little effort put into end-to-end system tests, and that's a shame. The really tricky bugs come from module/process interaction. Furthermore, unlike Unit Tests, system tests reflect the end-user experience. At one place where I worked, the software was just pure crap, but the system testing was thorough and the customers loved the product.
Test 1 2 3 4
My idea would be to tackle the mocking scenario by intercepting methods with AOP (AspectJ most likely) and subsituting mocked return values. This would at least make it possible to unit test legacy code without major refactoring and avoid some really questionable design decisions that junit sometimes forces you into.
Your pizza just the way you ought to have it.
At any major development place, *everything* is unit tested. Code coverage (how many lines of code are actually covered by the tests) is huge and should usually be above 70%. Unit tests aren't to make sure that your code is working correctly right now, unit tests are so that in 5 years when you change one class out of 6000 interdependant classes you can just run "ant test" and it goes back, runs all your tests and makes sure they still pass as they did when you first wrote it 5 years prior. Without unit testing, modifying any major, complex piece of software would be hopeless. You can unit test anything, including apps that require databases. You simply "mock out" the database using JMock and it stands in place for it like a fake database almost. The development I do is heavily dependant on Oracle and Java and JUnit/JMock are critical to the project's success. It is a common practice in open source now too as was seen by the recent release of Gallery 2.0 which is largely unit tested.
Regards,
Steve
as soon as I saw you had to create a freaking XML file I stopped reading. eclipse can run junits without all the xml junk. java and XML don't require each other!
PHP is the solution of choice for relaying mysql errors to web users.