Quickly disabling tests
Ever needed to disable all (or most) tests in a JUnit test case? How about this: Using the editor of your choice, search for “void test” and replace all of them with “void dtest” (“d” as in disabled)....
View ArticleTesting the Impossible: JavaScript in a Web Page
How do you run JUnit tests on JavaScript in a web page? Impossible? Here is what you need: First, get a copy of Rhino (at least 1.6R7). Then, save a copy of the JavaScript code at the bottom as...
View ArticleTesting The Impossible: Inserting Into Database
Tests run slow when you need a database. An in-memory database like HSQLDB or Derby helps but at a cost: Your real database will accept some SQL which your test database won’t. So the question is: How...
View ArticleHidden JUnit features: @Rules
@Rules seem a better solution than @RunWith to do some special work before/after a test. The release notes mention a couple of ideas: Notification on tests Setting up or tearing down resources,...
View ArticleUseful JUnit Helper Method: ignoreUntil()
We all know the pattern: A test fails but you can’t fix it right away. What do you do? Let it stay red? @Ignore it? All those approaches have drawbacks. Red tests make me nervous. But when I add an...
View ArticleAgileUnit – The Future Of Testing?
AgileUnit is a new testing framework which puts the testing code and all your assumptions into the business logic. The main advantage is that you can make sure that your assumptions are met as the...
View ArticleEclipse Suddenly Takes Long to Start Unit Tests
When starting a JUnit test in Eclipse suddenly takes ages (the process starts quickly as you can see in the Console view but it takes ages until the tree of tests appears in the JUnit view), you might...
View Article