Which dependencies do I need to use Mockito and JUnit in an Eclipse RCP Tycho project

前端 未结 1 1528
情歌与酒
情歌与酒 2021-02-20 14:18

This is my current test fragment:

eclipse-test-plugin


    <         


        
1条回答
  •  迷失自我
    2021-02-20 14:40

    I have found that the wrapper bundles of JUnit, Hamcrest, and Mockito from the Eclipse Orbit work well together.

    For the (currently) latest Orbit release, which includes JUnit 4.11, Hamcrest 1.1 (with Hamcrest Core in version 1.3), and Mockito 1.8.4, just add the following snippet to your POM:

    
        
            orbit-kepler
            http://download.eclipse.org/tools/orbit/downloads/drops/R20130517111416/repository/
            p2
        
    
    

    In the wrappers of the Eclipse Orbit, the org.junit bundle exports parts of the package org.hamcrest.core. Mockito however needs the complete content of the org.hamcrest.core package. In order to prevent accidental wiring between the Mockito and JUnit bundle, the export is marked with a mandatory attribute. Unfortunately, p2 doesn't take these into account (and Tycho uses p2 for dependency resolution), so you need to give the dependency resolution of your fragment (using Mockito) an extra hint:

    
        org.eclipse.tycho
        target-platform-configuration
        ${tycho-version}
        
            
                
                    
                        eclipse-plugin
                        org.hamcrest
                        0.0.0
                    
                
            
        
    
    

    This makes sure that the org.hamcrest bundle is used during dependency resolution, and that Mokito's imports can be wired successfully.

    0 讨论(0)
提交回复
热议问题