Nice things

Posted on April 15, 2007

I found two new interesting things:

First one is a Java tool called Ashcroft that helps to write real varunit test. It is very simple, all you have to do it add a parameter -Djava.security.manager=com.thoughtworks.ashcroft.runtime.JohnAshcroft to the java commands that starts the unit test and it will throw an exception whenever you are not following one of the Ten Commandments of Unit Tests:

  1. I am the class being tested. Thou shalt not test any other class but me.
  2. Thou shalt write isolated tests
  3. Thou shalt not access files during unit tests
  4. Thou shalt not write two tests which depend upon each other

Why this is such a nice tool? Well unit test are supposed to be very fast, so that you can run then very frequently. And this tool helps you to be more disciplined. So instead of calling a read database or reading an XML from a file system, you have to proviced a mock or a stab object. And this really helps, I modified my unites test that that triggered the Ashcroft to throw an exception and now they run in 1 second instead of 5.

The second trick is very simple:

startTicking( toDo == 'A' ? 500: // agony
toDo == 'S' ? 150: // slow
toDo == 'S' ? 70: // medium
toDo == 'S' ? 30: 0); // fast

Filed Under Uncategorized |

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name

Email

Website

Comments

For spam detection purposes, please copy the number 6231 to the field below:

© Copyright 0xDEADBEEFCAFE • Powered by Wordpress • Design by Sebastin.

free web hit counter