Developers, Developers, Developers! Maksim Sorokin IT Blog

21Dec/10Off

Tests in Tycho

In Tycho tests expected to have the following name pattern: **/Test*.java, **/*Test.java and **/*TestCase.java. By default, the following is excluded: **/Abstract*Test.java**/Abstract*TestCase.java and **/*$*.

If you want to change excluded and included tests, in your test fragment you have to add something like the following:

<build>
  <plugins>
    <plugin>
      <groupId>org.sonatype.tycho</groupId>
      <artifactId>maven-osgi-test-plugin</artifactId>
      <version>${tycho-version}</version>
      <configuration>
        <excludes>
          <exclude>**/BasicTest.java</exclude>
        </excludes>
        <includes>
          <include>**/CalcRunnerCase.java</include>
        </includes>
      </configuration>
    </plugin>
  </plugins>
</build>

Keep in mind, that if tycho will not find any tests, it will fail! See discussion on issue tracker.

23Mar/10Off

Eclipse “Favorites” and JUnit 4 Static Imports Revised

After some time of using static imports workaround for JUnit 4 and EasyMock described earlier I came to the conclusion, that editing import "favorites" is not a good idea.

The problem is that when you include a class with static methods in Eclipse "favorites", then in Content Assistant you see hundred of those static methods. This maybe somewhat inconvenient. Moreover, Content Assistant hangs a bit longer before appearing.

From now on I am directly using class name like Assert.assert.. or EasyMock.expect.. instead of using static imports.

12Feb/10Off

Eclipse and JUnit 4 Static Imports

Importing static JUnit 4 annotations in Eclipse is somewhat boring. The thing is that by default Eclipse doesn't import static fields or methods.

The most optimal way is to add junit.framework.Assert to "favorite" static types. Then, assertion methods will be seen in editor.
How to:

  • Menu -> Window -> Preferences
  • Java -> Editor -> Content Assist -> Favorites
  • New Type: junit.framework.Assert

P.S.: idea taken from http://blog.xebia.com/2008/10/12/eclipse-tip-keep-static-imports-for-junit-4/