Make Fireworks IntelliJ Plugin Ignore Integration Tests


http://www.wafermaneuver.com/nick/img/photo/fireworks2.jpg

The Fireworks Plugin for IntelliJ allows you to automatically run all your unit tests when you make a change to the code.

Its a well behaved plugin, it allows you to configure wether or not to do this so you can just turn it on or off.

Whilst using it I made a detour to Shave a couple of Yaks. So thought I’d document it here.

I found it was also running some integration tests which relied on the file system and so didn’t work because there doesn’t appear to be a way to specify the working directory (you can specify JVM args so I could use that instead. I submitted an issue.

In the mean time, actually I thought I would rather not run my integration tests. Fortunately Fireworks allows a regex pattern to decide which files are tests.

After some hunting, I found the following post on stack overflow which gave me the clues i needed to include Test but not IntegrationTest.

The solution takes advantage of “lookaround” features of regex. The syntax in question is:

(?!Integration)

The (?! regex ) syntax means negative look ahead. You can put any regex in there. In our case, just “Integration”. This says, something not followed by “Integration”.

The code on stack overflow had some unnescessary syntax at the beginning (^) and I changed the ordering around a bit to make it read more logically.

(.(?!Integration))*Test

The first “^” was unnescessary, and putting the “.” first made it read better i think. The parentheses are to provide some structure (regex groups) more than any functional reason.

So in words, the new expression reads “match any repeating character (.*) not followed by “Integration” (?!Integration)), then only match if “Test” is on the end.

Here is a test case for it (which along with some other regex stuff can be found on Github :

    @Test
    public void matchesUnitTestsButNotIntegrationTests() {
        String expression = “(.(?!Integration))*Test”;
        Pattern pattern = Pattern.compile(expression);
        assertThat(pattern.matcher(“SomeUnitTest”).matches(), is(true));
        assertThat(pattern.matcher(“SomeIntegrationTest”).matches(), is(false));
        assertThat(pattern.matcher(“SomeNonTestClass”).matches(), is(false));
    }

I found it hard to get this to work on the command line with grep. But I’ve got too much YAK HAIR on my floor now!

Now the Yaks are shaved I can go back to putting a system property in to allow my integration test to work.

Share