0

I created a plain old JAR with some fancy test classes I want to use to make testing more easy and fun.

Everybody knows Eclipse plug-ins aren't for unit testing and Tycho doesn't allow it, but we already managed a setup where we can test plug-ins using Surefire exactly the same way we test pure Maven projects. Using <pomDependencies>consider</pomDependencies> in the config of the target-platform-configuration allows for adding plain old Maven dependencies, so the Tycho build already works with the new fancy test classes.

Not Eclipse though. Plug-ins are missing the library "Maven Depdencies", and even adding it via the "Java Build Path" in the settings does nothing. I can add the project with the test classes there, but that would mean checking it from SVN and adding it to every workspace (I have 100, and I can't rule out that other people are working here, too).

On the other hand I can't just add it to the Manifest.MF because that would mean the test library would be shipped to our customers (which fancy or not is a bad idea). And I don't know how Tycho feels about optional dependencies, it's probably not a fan (and I feel like this would be bad style).

So how can I trick a plug-in in Eclipse into accepting a dependency that is not in the final plug-in?

Stefan S.
  • 3,950
  • 5
  • 25
  • 77
  • Can you elaborate what you mean by "Eclipse plug-ins aren't for unit testing and Tycho doesn't allow it"? Tycho and Eclipse are certainly very supportive of unit testing, so I suspect you mean something very specific that isn't obvious in the question. – E-Riz Nov 04 '15 at 15:28
  • @E-Riz They do? That's certainly new. Up to two weeks ago both only supported integration tests (packaging type `eclipse-test-plugin`). – Stefan S. Nov 05 '15 at 06:24
  • I still don't know what you mean. I've written tons of unit tests for plug-ins, and the Eclipse code-base itself (which is built with Tycho) is very well unit-tested. – E-Riz Nov 05 '15 at 13:59
  • Perhaps my answer to this related question will help: http://stackoverflow.com/a/33546771/639520 – E-Riz Nov 05 '15 at 14:14
  • Of course Tycho runs unit tests, it just does it in the integration phase instead of the traditional testing phase. See http://stackoverflow.com/questions/28721925/is-it-possible-to-configure-tycho-surefire-to-run-in-the-test-phase There may very well be a way to do what you are asking, and I look forward to see if there are answers. – Jonah Graham Nov 05 '15 at 20:07
  • @E-Riz Tycho runs test in the integration test phase, takes ages to start the OSGi context AND you have to configure all your dependencies for the third time (the other two being the Manifest of the plug-in and the target platform). That's not even close to unit tests. – Stefan S. Nov 06 '15 at 06:53
  • @JonahGraham The answer to your link is what we are doing, unit tests in the same plug-in. Which leads to the question at hand. – Stefan S. Nov 06 '15 at 06:54
  • @SteffiS. I hadn't understand that from your question. I thought you were trying to run tests in in test phase (which would need extra deps) rather than plugin + tests in the same plug-in. I may actually have an answer for you on that. Let me look something up. – Jonah Graham Nov 06 '15 at 07:33
  • I got rid of my answer since I so completely misunderstood. Good luck on finding a solution. – Jonah Graham Nov 06 '15 at 10:09

0 Answers0