Automatic testing in Groovy from command line

If you have a need to do some automatic testing from the command line, Groovy can be of much help. Here’s a quick way to set this up. First, make sure you have both Groovy and Ant installed and the respective libraries in your PATH or CLASSPATH. For example, if you don’t have Ant installed, you can get exceptions such as:

Caught: java.lang.NoClassDefFoundError: org/apache/tools/ant/DemuxInputStream
  at groovy.util.FileNameFinder.class$(FileNameFinder.groovy)
  at groovy.util.FileNameFinder.$get$$class$groovy$util$AntBuilder(FileNameFinder.groovy)
  at groovy.util.FileNameFinder.getFileNames(FileNameFinder.groovy:37)
  at groovy.util.FileNameFinder.getFileNames(FileNameFinder.groovy:29)

Provided you have the above set up properly, here’s how you can make a simple test suite:

// Save this as AllTests.groovy
def ats = new groovy.util.AllTestSuite()
def suite = ats.suite("test", "**/*Test.groovy")

The above makes the AllTestsSuite, tells it to search the tests in “test” folder and also tells it to only consider files that match “*Test.groovy” (e.g. OneTest.groovy, MyCalculatorTest.groovy, etc.). Now, let’s make the test folder and put two sample tests in it:

// Save this to test/OneTest.groovy
class OneTest extends groovy.util.GroovyTestCase {
  void testOne1() {
    assert 1 == 1
  void testOne2() {
    assert 1 == 1

// Save this to test/TwoTest.groovy
class TwoTest extends groovy.util.GroovyTestCase {
  void testTwo1() {
    assert 1 == 1
  void testTwo2() {
    assert 1 == 1

If you now run this:

$ groovy AllTests.groovy

it should run all your tests and print something like this:


Time: 0.012

OK (4 tests)

Note that it’s not usual to use println in your tests – the above is just to make it obvious that the test suite we made executes all the tests. A good thing about this solution is that you don’t need to update the list of tests. If you want to make another test case, just make another file (e.g. LottoWinnerTest.groovy) and put it in test folder. AllTestSuite will find it automatically. Also, if you ever need to remove some of your tests, simply move them from test folder to some other location. All is very DRY.

General aviation – most common aircraft models

I was reading some private aviation articles a few days ago. Private aviation is a term used for describing airplanes and their use for civil and non-commercial purposes. Most common in this category are propeller-based, piston-powered, single-engine airplanes. There are many manufacturers of such kinds of planes, here are some of them:

  • Beechcraft
  • Cessna
  • Cirrus
  • Diamond
  • Mooney
  • Piper

I wanted to know which are the most common ones. Taking a look at numerous sites where you can buy different aircrafts, the distribution is roughly like this:

manufacturer percentage
Cessna 44
Piper 26
Beechcraft 11
Cirrus 4
Diamond 3

Note this is only for the above 5 most common – the above adds up to 100%, but the above aircraft don’t make the 100% of all the aircraft models. The rest, however, don’t add up to many percents, at least according to the brief study I made. Also note this is not a scientific thing for other reasons – just a compilation from a few sites and thus can change a lot depending on several factors – current economics, region of the world, etc.

Even though, it gives you a good picture. The above says that you can expect, say, 2/3 common private aviation planes to be either Cessna or Piper. This may mean a few things for potential buyers or renters:

  • You are more likely to run into these kinds of planes (= less time to learn)
    • Maintenance is easier for several reasons:
    • People, like other pilots, are familiar (= can offer better advice),
    • Parts are easier to find (= better quality and less expensive),
    • Mechanics are more familiar (= can fix it faster, better, for less money)
  • You are more likely to find an instructor familiar with these (= they will be able to teach you better).
  • Books are more likely to consider one of the above when discussing (= explanations and pictures are more specific)

The whole reason I did the above research is to see whether it’s worth risking and tying yourself to a specific make/model. I think I am pretty sure I’m going to stick with Cessna after the above – it’s a very good starting point and that might prove invaluable. If for no other reason, it might mean a decisive thing when walking the thin line between flying or not. Flying requires a serious dedication both in time and money, so anything that helps is welcome from my standpoint of view.