Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Buckminster » How to organize JUnit tests for running with Buckminster
How to organize JUnit tests for running with Buckminster [message #775220] Thu, 05 January 2012 15:22 Go to next message
Matthew Webber is currently offline Matthew WebberFriend
Messages: 198
Registered: December 2010
Senior Member
We currently run our JUnit tests using Ant. I'd like to replace this with the Buckminster junit command, but I can't create a suitable launch configuration.

Currently, we use this ant:
<junit dir="@{dir}">
    <classpath>
        manually maintained in sync with the plugin dependencies
    </classpath>
    <batchtest todir="@{report.dir}">
        <fileset dir="${GDA-plugin.basedir}/test">
            <include name="**/*Test.java" />
            <exclude name="**/*PluginTest.java" />
        </fileset>
    </batchtest>
</junit>

The nice thing about this arrangement is that when our developers add a new test, it gets automatically run provided that class name ends in Test.

I want to do the same thing using the Buckminster junit command, but it requires a suitable .launch configuration. It looks like Eclipse launch configurations can only run either a single test, or all the tests in a project, package or source folder. There doesn't seem to be any other way of selecting tests. In particular, I can't discriminate between JUnit and JUnit Plugin tests.

There are lots of good reasons to use Buckminster to run my JUnit tests:
(1) I don't need to maintain a separate test classpath, since Eclipse/Buckminster understands the plugin dependencies
(2) The infrastructure used to run tests is the same in the IDE and in the batch test environment

But I'm stuck, seemingly due to the inflexibility of launch configurations. So, how do the rest of you do this? I'd really like to keep the automatic test discovery that we currently have.

We use JUnit 4 exclusively. We don't use test suites to define the tests to run, just the *Test.java pattern.

Thanks for any suggestions.
Matthew



Re: How to organize JUnit tests for running with Buckminster [message #775350 is a reply to message #775220] Thu, 05 January 2012 20:24 Go to previous messageGo to next message
Thomas Hallgren is currently offline Thomas HallgrenFriend
Messages: 3240
Registered: July 2009
Senior Member
Hi Matthew,

I understand your dilemma and I agree it would be great to have a
mechanism whereby tests could be automatically detected and added. As
you've discovered, the launch configuration offers no such flexibility
which leaves us with two options.

1. Buckminster adds a more flexible launch command that can detect
launch configurations using some ant-linke pattern and then execute them
all.

2. You execute a JUnit test which in turn performs some discovery. I
don't think that should be too hard actually, especially if you're doing
this in the OSGi domain. A developer that provides a test would simply
add it as an OSGi service and then the JUnit test launched by the
Buckminster launcher would run all such services.

You will need two bundles in order to make this happen. They are fairly
common so chances are you already have them:

org.eclipse.equinox.ds
org.eclipse.equinox.util

For more info about how to add declarative services I can recommend
reading this article:

http://www.vogella.de/articles/OSGi/ar01s07.html

HTH,
Thomas Hallgren


On 2012-01-05 16:22, Matthew Webber wrote:
> We currently run our JUnit tests using Ant. I'd like to replace this
> with the Buckminster junit command, but I can't create a suitable launch
> configuration.
>
> Currently, we use this ant:
> <junit dir="@{dir}">
> <classpath>
> manually maintained in sync with the plugin dependencies
> </classpath>
> <batchtest todir="@{report.dir}">
> <fileset dir="${GDA-plugin.basedir}/test">
> <include name="**/*Test.java" />
> <exclude name="**/*PluginTest.java" />
> </fileset>
> </batchtest>
> </junit>
> The nice thing about this arrangement is that when our developers add a
> new test, it gets automatically run provided that class name ends in Test.
>
> I want to do the same thing using the Buckminster junit command, but it
> requires a suitable .launch configuration. It looks like Eclipse launch
> configurations can only run either a single test, or all the tests in a
> project, package or source folder. There doesn't seem to be any other
> way of selecting tests. In particular, I can't discriminate between
> JUnit and JUnit Plugin tests.
>
> There are lots of good reasons to use Buckminster to run my JUnit tests:
> (1) I don't need to maintain a separate test classpath, since
> Eclipse/Buckminster understands the plugin dependencies
> (2) The infrastructure used to run tests is the same in the IDE and in
> the batch test environment
>
> But I'm stuck, seemingly due to the inflexibility of launch
> configurations. So, how do the rest of you do this? I'd really like to
> keep the automatic test discovery that we currently have.
>
> We use JUnit 4 exclusively. We don't use test suites to define the tests
> to run, just the *Test.java pattern.
>
> Thanks for any suggestions.
> Matthew
>
>
>
>
Re: How to organize JUnit tests for running with Buckminster [message #775574 is a reply to message #775350] Fri, 06 January 2012 09:48 Go to previous messageGo to next message
Matthew Webber is currently offline Matthew WebberFriend
Messages: 198
Registered: December 2010
Senior Member
Thnaks for the feedback, Thomas. Further googling merely confirmed that there is no standard way to do this, but I did find ClasspathSuite (http://johanneslink.net/projects/cpsuite.jsp) which a number of folks seem to be using successfully.

The library internally scans the classpath for classes with JUnit4 annotated methods and then executes all found tests. You can also filter using wildcards etc. Effectively it builds a test suite dynamically.

Unfortunately it doesn't work with plugin tests, but other than that seems worth a look. I will try it out and post my experiences back here.

Matthew
Re: How to organize JUnit tests for running with Buckminster [message #883883 is a reply to message #775220] Sat, 09 June 2012 17:03 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 01/05/2012 04:22 PM, Matthew Webber wrote:
> I want to do the same thing using the Buckminster junit command, but it
> requires a suitable .launch configuration. It looks like Eclipse launch
> configurations can only run either a single test, or all the tests in a
> project, package or source folder. There doesn't seem to be any other
> way of selecting tests. In particular, I can't discriminate between
> JUnit and JUnit Plugin tests.

Hi

probably I'm missing something but I usually create a test suite for all
my junit tests and one for all my junit plugin tests. For the junit
plugin tests suite I create from Eclipse a junit plugin launch
configuration based on a single test feature, and this works fine when
run from Buckminster...

cheers
Lorenzo

--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
ICQ# lbetto, 16080134 (GNU/Linux User # 158233)
HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com
http://www.myspace.com/supertrouperabba
BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com
http://www.gnu.org/software/src-highlite
http://www.gnu.org/software/gengetopt
http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net


Re: How to organize JUnit tests for running with Buckminster [message #888661 is a reply to message #883883] Mon, 18 June 2012 12:45 Go to previous message
Matthew Webber is currently offline Matthew WebberFriend
Messages: 198
Registered: December 2010
Senior Member
Yes, using a Test Suite will work. However, we actually moved away from using test suits, because developers were writing tests but the forgetting to add them to the test suite. The nice thing about our current arrangement is that when our developers add a new test, it gets automatically run provided that class name ends in Test.

We would be prefer to use this test discovery, rather than listing the tests to be run, if possible.
Previous Topic:creating a repository keeping all the versions
Next Topic:Materialize from git fails if slash in branch name
Goto Forum:
  


Current Time: Tue Mar 19 04:15:55 GMT 2024

Powered by FUDForum. Page generated in 0.02612 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top