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

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

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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

        Attachments

          Activity

          Hide
          scm_issue_link 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

          Show
          scm_issue_link 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
          Hide
          scm_issue_link 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

          Show
          scm_issue_link 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

            People

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

              Dates

              • Created:
                Updated:
                Resolved: