Sunday, March 11, 2012

BitBucket offers free unlimited git PRIVATE repos

I am really growing to like git and the distributed way of version control and I have to acknowledge GitHub as a very popular place for social coding.  I've noticed one thing, though, that's prevented me from using it: you have to pay for private repositories (US$7/mo as of this writing).

Fortunately, I noticed that BitBucket, from Atlassian, not only has added git support (I was using it with Mercurial), they also support unlimited public and private repositories and up to five users for free, with reasonable paid plans from there.

In fact, all plans support unlimited public & private repos, and it seems to have most if not all of the same bells & whistles (issue tracking, wiki, pull requests, etc). I think it beats GitHub for small projects that you don't want to share just yet (if ever).

I wonder what would have happened if BitBucket had offered git before GitHub did -- maybe BitBucket would have been the new, cool place to store your code!

Anyway, just thought I'd let people know about the great service.

Saturday, March 10, 2012

Running TestNG & JUnit 4 tests in the same Maven project without duplication

Update on 16 Mar '12:  Cedric has informed me that the TestNG master branch now supports JUnit 4.  Try it out!

As of this writing, TestNG still doesn't support JUnit4.  Problem is, Spring Roo uses JUnit 4 and I happen to be developing a liking for TestNG lately.

Many folks out there have suggested defining two Surefire executions, one for JUnit 4 & one for TestNG.  I did that, but every time I do, it looks like the default configuration of Surefire runs first, then whatever other test executions that you've defined next, often resulting in duplicate tests being run.

I noticed that the default Surefire execution id is default-test.  By simply defining an execution with id default-test and setting skipTests to true, I was able to avoid the unwanted default run.  You could either redefine the default-test execution or defeat it and define whatever other test executions you want to.

Here's the POM snippet that defeats the default-test execution and defines one for JUnit 4 & TestNG:

    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.11</version>
        <executions>
            <execution>
                <id>default-test</id>
                <configuration>
                    <skipTests>true</skipTests>
                </configuration>
                <goals>
                    <goal>test</goal>
                </goals>
            </execution>
            <execution>
                <id>junit-tests</id>
                <goals>
                    <goal>test</goal>
                </goals>
                <configuration>
                    <testNGArtifactName>none:none</testNGArtifactName>
                    ...
                </configuration>
            </execution>
            <execution>
                <id>testng-tests</id>
                <goals>
                    <goal>test</goal>
                </goals>
                <configuration>
                    <junitArtifactName>none:none</junitArtifactName>
                    ...
                </configuration>
            </execution>
        </executions>
    </plugin>

I hope this helps you some time.