[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [tycho-user] Issue with getting emails from tycho-user & rephrasing question about unit tests
|
On 04/05/2016 08:02 PM, Brian de Alwis wrote:
You seem to be mixing Maven dependencies and OSGi dependencies. That might work with pomDependencies=consider, but I’ve done my best to avoid this situation entirely:
https://wiki.eclipse.org/Tycho/How_Tos/Dependency_on_pom-first_artifacts
I instead pull Mockito and Hamcrest from Eclipse Orbit.
But beware Mockito: there are a number of open bug reports on problems with Mockito and Hamcrest. They boil down to problems due to split packages across org.hamcrest.*, plus incompatible changes made to the Hamcrest API. You must pull in the org.hamcrest bundle, a facade bundle that pulls in the split packages and re-exports the org.hamcrest package.
I avoid Hamcrest entirely, so hopefully that won't be a problem. I get
by with AssertJ.
What's not clear to me is whether I can run "true" unit tests (not
bundle tests) this way, both interactively in Eclipse and with Surefire
from the command line. I've seen "tycho-surefire-plugin", but that
doesn't seem like it's doing true unit tests, more like integration tests.
I was able to get something working, but it required me effectively
duplicating my test dependencies, one so I can run them interactively in
Eclipse, and one to work with Surefire in the build. It works, but it's
really a mess.
Brian.
On 5-Apr-2016, at 11:41 AM, David M. Karr <davidmichaelkarr@xxxxxxxxx> wrote:
In my subscription options for "tycho-user", I have "Receive your own posts to the list?" set to "Yes". However, I never receive my own posts to this list. Why is that?
I asked yesterday about how to get unit tests running in a Tycho-built project. I'm going to rephrase this with more detail. I would have responded to my own post, but ...
In my codebase with a multi-module Maven Tycho build, there are several plugin projects. I'm trying to add unit tests to one of them, using JUnit and Mockito.
As I'm not aware of a p2 repo with JUnit or Mockito, I figured I would have to continue using the "maven-dependency-plugin" to get Maven artifacts available for my plugin. My manifest has "Build-Classpath" entries referring to the "junit" and "mockito-all" jars, which appear to be valid. This is done in a different plugin, and the plugin with the unit tests depends on that other plugin.
However, when I run the build, I get the following excerpt from the build (home path elided):
----------------------
[INFO] --- tycho-compiler-plugin:0.24.0:compile (default-compile) @ com.cisco.yangide.ext.model.editor ---
[WARNING] The effective compiler target level 1.8 is incompatible with the following OSGi execution environments: [JavaSE-1.7 (assumes 1.7)] @ MavenProject: org.opendaylight.yangide:com.cisco.yangide.ext.model.editor:1.1.1-SNAPSHOT @ .../git/yangide/plugins/com.cisco.yangide.ext.model.editor/pom.xml
[INFO] Compiling 105 source files to .../git/yangide/plugins/com.cisco.yangide.ext.model.editor/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32.542 s
[INFO] Finished at: 2016-04-05T08:32:32-07:00
[INFO] Final Memory: 109M/603M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.eclipse.tycho:tycho-compiler-plugin:0.24.0:compile (default-compile) on project com.cisco.yangide.ext.model.editor: Compilation failure: Compilation failure:
[ERROR] .../git/yangide/plugins/com.cisco.yangide.ext.model.editor/src/test/java/com/cisco/yangide/ext/model/editor/YinBuilderTest.java:[12]
[ERROR] import static org.mockito.Mockito.*;
[ERROR] ^^^^^^^^^^^
[ERROR] The import org.mockito cannot be resolved
-----------------
In non-Eclipse Maven builds, I'm used to seeing Surefire compiling unit tests. It appears that the "tycho-compiler-plugin" is compiling them here. I don't know whether that's expected or not.
I also ran the build with "-X", and this is an excerpt that shows "junit" and "mockito-all" in the dependency tree:
-------------------
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=0, ConflictMarker.markTime=1, ConflictMarker.nodeCount=230, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=0, ConflictIdSorter.conflictIdCount=229, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=14, ConflictResolver.conflictItemCount=229, DefaultDependencyCollector.collectTime=7, DefaultDependencyCollector.transformTime=15}
[DEBUG] org.opendaylight.yangide:com.cisco.yangide.ext.model.editor:eclipse-plugin:1.1.1-SNAPSHOT
[DEBUG] junit:junit:jar:4.12:test
[DEBUG] org.hamcrest:hamcrest-core:jar:1.3:test (scope managed from compile by org.opendaylight.odlparent:odlparent:[unknown-version])
[DEBUG] org.mockito:mockito-all:jar:1.10.19:test
[DEBUG] p2.eclipse-plugin:org.eclipse.core.runtime:jar:3.11.1.v20150903-1804:system
-----------------
So what might I be doing wrong here?
_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-user
_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/tycho-user