The funniest piece of unit test code I have seen in long time
Added: August 25, 2009
While I was wading through some tests recently I have found following piece of code. I thought you might enjoy it too.
@BeforeClass public static void setUpBeforeClass() throws Exception { System.out.println("BeforeClass"); main(null); } public void testDummy() { // do nothing } public static void main(String [] args) throws Exception { System.out.println("main"); // a lot of code is here }The point is that given test class is meant for setting up an environment and it does not contain any real test methods. It is just an inconvenient way to use convenience of JUnit for execution of some code. Please, do not do these things!