Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running JUnit tests from multiple projects in Eclipse

It's possible I'm losing my mind, but this morning when I upgraded to Eclipse Kepler I tried to run unit tests for multiple Eclipse projects at the same time and failed. I selected multiple projects, opened the right-click menu and the "Run as..." options were gone.

"Damn Kepler!" I thought and fired up my old Juno install to convince myself the behaviour had changed. However, it didn't work in there either.

I'm now questioning my sanity over whether this was ever truly possible. Many other Stack Overflow questions and other sites suggest this is a difficult, if not impossible task. However, I'm so sure I was doing this in the recent past that it's left me a little rattled.

So... has this even been possible, either in Kepler or Juno? Can anyone suggest a popular plugin that might have enabled that feature (which I incorrectly assumed to be default behaviour)?

Background: I have a multi-module Maven project managed through m2e and expected I could select several of the projects and run all the unit tests.

like image 514
Duncan Jones Avatar asked Jun 27 '13 10:06

Duncan Jones


1 Answers

You can perform JUnit tests across multiple projects using Classpath Suite. In general all you need to do is:

  1. Create an Eclipse project depending on all the projects you want to test.
  2. Write a suite:

    @RunWith(ClasspathSuite.class)
    public class MySuite

Take a look on this article: Roger Rabbit - JUnit Tests Runner Across Multiple Projects, it includes a step by step example and a code sample.

like image 148
Effi Bar-She'an Avatar answered Sep 17 '22 14:09

Effi Bar-She'an