Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-39362

Build test classpath is inconsistent: mockito-all clashes with hamcrest-core

      Trying to implement semantically improved unit test results in a runtime error:

      mvn test -Dtest=MatcherTest -Dconcurrency=1 -DtrimStackTrace=false
      
      -------------------------------------------------------------------------------
      Test set: hudson.plugins.promoted_builds.MatcherTest
      -------------------------------------------------------------------------------
      Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.068 sec <<< FAILURE! - in hudson.plugins.promoted_builds.MatcherTest
      test(hudson.plugins.promoted_builds.MatcherTest)  Time elapsed: 0.008 sec  <<< ERROR!
      java.lang.NoSuchMethodError: org.hamcrest.Matcher.describeMismatch(Ljava/lang/Object;Lorg/hamcrest/Description;)V
      	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18)
      	at org.junit.Assert.assertThat(Assert.java:956)
      	at org.junit.Assert.assertThat(Assert.java:923)
      	at hudson.plugins.promoted_builds.MatcherTest.test(MatcherTest.java:14)
      
      package hudson.plugins.promoted_builds;
      
      import org.hamcrest.BaseMatcher;
      import org.hamcrest.Description;
      import org.junit.Test;
      
      import static org.junit.Assert.assertThat;
      
      public class MatcherTest {
          @Test
          public void test() throws Throwable {
              // object to perform assertion against
              final Object actual = new Object();
              assertThat(actual, new BaseMatcher() {
                  @Override
                  public void describeTo(Description description) {
                      description.appendText("custom description");
                  }
                  @Override
                  public boolean matches(Object item) {
                      // for demonstration purpose
                      return false;
                  }
              });
          }
      }
      

      This is caused by org.hamcrest.Matcher being provided by both hamcrest-core:1.3 and mockito-all:1.8.5

      Workaround: give up creating semantically improved assertions and do low level assertions

          [JENKINS-39362] Build test classpath is inconsistent: mockito-all clashes with hamcrest-core

          Code changed in jenkins
          User: Fiouz
          Path:
          pom.xml
          src/test/java/hudson/plugins/promoted_builds/TestingFrameworkTest.java
          http://jenkins-ci.org/commit/promoted-builds-plugin/81107d3063be7b73fcc67aa9bb791c69932fac4b
          Log:
          [FIXED JENKINS-39362] Replace mockito-all by mockito-core

          This avoid problems caused by duplicated classes between mockito-all and
          other testing libraries

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Fiouz Path: pom.xml src/test/java/hudson/plugins/promoted_builds/TestingFrameworkTest.java http://jenkins-ci.org/commit/promoted-builds-plugin/81107d3063be7b73fcc67aa9bb791c69932fac4b Log: [FIXED JENKINS-39362] Replace mockito-all by mockito-core This avoid problems caused by duplicated classes between mockito-all and other testing libraries

          Code changed in jenkins
          User: Oleg Nenashev
          Path:
          pom.xml
          src/test/java/hudson/plugins/promoted_builds/TestingFrameworkTest.java
          http://jenkins-ci.org/commit/promoted-builds-plugin/fecfe02324daa001fc46c73600f01ee33016c4bf
          Log:
          Merge pull request #97 from Fiouz/JENKINS-39362

          [FIXED JENKINS-39362] Replace mockito-all by mockito-core

          Compare: https://github.com/jenkinsci/promoted-builds-plugin/compare/f7589c3c3e76...fecfe02324da

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Oleg Nenashev Path: pom.xml src/test/java/hudson/plugins/promoted_builds/TestingFrameworkTest.java http://jenkins-ci.org/commit/promoted-builds-plugin/fecfe02324daa001fc46c73600f01ee33016c4bf Log: Merge pull request #97 from Fiouz/ JENKINS-39362 [FIXED JENKINS-39362] Replace mockito-all by mockito-core Compare: https://github.com/jenkinsci/promoted-builds-plugin/compare/f7589c3c3e76...fecfe02324da

            oleg_nenashev Oleg Nenashev
            fchuong Frédéric Chuong
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: