Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] obfuscation and unit tests

Hi Justin,

> I can work out obfuscating my eclipse-plugin project, but am not sure
> what to do about the accompanying eclipse-test-plugin project.
> Specifically, since the tests are run against the packaged jar, tests I
> have for the classes which have now been obfuscated fail to compile.
> With Ant I would compile/run the tests against the unobfuscated class
> files. What’s the recommended way to handle this with Tycho projects?

we have run into this issue as well. There are AFAIK two options, none
of which is great:

- Use Maven profiles to make test execution and obfuscation mutually
exclusive, e.g., only obfuscate when using -Prelease and then
-DskipTests. Unfortunately, your tests then won't catch breakage due to
misconfigured obfuscation anymore.

- Use Guava's @VisibleForTesting or a similar annotation to selectively
exclude some methods from obfuscation, effectively making your test API
entrypoints. This of course has the drawback that the more you test the
less you obfuscate.

If there's a better solution then I would like to hear of it, of course.

Hope this helps anyway.

Andreas

-- 
Codetrails GmbH
The knowledge transfer company

Robert-Bosch-Str. 7, 64293 Darmstadt
Phone: +49-6151-276-7092
Mobile: +49-170-811-3791
http://www.codetrails.com/

Managing Director: Dr. Marcel Bruch
Handelsregister: Darmstadt HRB 91940


Back to the top