• java.lang.NoClassDefFoundError: org/junit/internal/AssumptionViolatedException


    1、错误描述

    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    java.lang.NoClassDefFoundError: org/junit/internal/AssumptionViolatedException
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
    	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    

    2、错误原因

    /*     */ package org.junit.internal;
    /*     */ 
    /*     */ import org.hamcrest.Description;
    /*     */ import org.hamcrest.Matcher;
    /*     */ import org.hamcrest.SelfDescribing;
    /*     */ import org.hamcrest.StringDescription;
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ public class AssumptionViolatedException
    /*     */   extends RuntimeException
    /*     */   implements SelfDescribing
    /*     */ {
    /*     */   private static final long serialVersionUID = 2L;
    /*     */   private final String fAssumption;
    /*     */   private final boolean fValueMatcher;
    /*     */   private final Object fValue;
    /*     */   private final Matcher<?> fMatcher;
    /*     */   
    /*     */   @Deprecated
    /*     */   public AssumptionViolatedException(String assumption, boolean hasValue, Object value, Matcher<?> matcher)
    /*     */   {
    /*  33 */     this.fAssumption = assumption;
    /*  34 */     this.fValue = value;
    /*  35 */     this.fMatcher = matcher;
    /*  36 */     this.fValueMatcher = hasValue;
    /*     */     
    /*  38 */     if ((value instanceof Throwable)) {
    /*  39 */       initCause((Throwable)value);
    /*     */     }
    /*     */   }
    /*     */   
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */   @Deprecated
    /*     */   public AssumptionViolatedException(Object value, Matcher<?> matcher)
    /*     */   {
    /*  51 */     this(null, true, value, matcher);
    /*     */   }
    /*     */   
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */   @Deprecated
    /*     */   public AssumptionViolatedException(String assumption, Object value, Matcher<?> matcher)
    /*     */   {
    /*  62 */     this(assumption, true, value, matcher);
    /*     */   }
    /*     */   
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */   @Deprecated
    /*     */   public AssumptionViolatedException(String assumption)
    /*     */   {
    /*  72 */     this(assumption, false, null, null);
    /*     */   }
    /*     */   
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */ 
    /*     */   @Deprecated
    /*     */   public AssumptionViolatedException(String assumption, Throwable e)
    /*     */   {
    /*  82 */     this(assumption, false, null, null);
    /*  83 */     initCause(e);
    /*     */   }
    /*     */   
    /*     */   public String getMessage()
    /*     */   {
    /*  88 */     return StringDescription.asString(this);
    /*     */   }
    /*     */   
    /*     */   public void describeTo(Description description) {
    /*  92 */     if (this.fAssumption != null) {
    /*  93 */       description.appendText(this.fAssumption);
    /*     */     }
    /*     */     
    /*  96 */     if (this.fValueMatcher)
    /*     */     {
    /*  98 */       if (this.fAssumption != null) {
    /*  99 */         description.appendText(": ");
    /*     */       }
    /*     */       
    /* 102 */       description.appendText("got: ");
    /* 103 */       description.appendValue(this.fValue);
    /*     */       
    /* 105 */       if (this.fMatcher != null) {
    /* 106 */         description.appendText(", expected: ");
    /* 107 */         description.appendDescriptionOf(this.fMatcher);
    /*     */       }
    /*     */     }
    /*     */   }
    /*     */ }
    
    /* Location:           C:UsersAdministratorDesktopjunit-4.12.jar
     * Qualified Name:     org.junit.internal.AssumptionViolatedException
     * Java Class Version: 5 (49.0)
     * JD-Core Version:    0.7.0.1
     */
         AssumptionViolatedException这个异常是实现SelfDescribing,但是SelfDescribing来自org.hamcrest.SelfDescribing

    3、解决办法

         下载hamcrest-core-1.1.jar拷贝到lib目录

          或者

          在pom.xml添加

    <!-- https://mvnrepository.com/artifact/org.hamcrest/hamcrest-core -->
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest-core</artifactId>
        <version>1.1</version>
    </dependency>


  • 相关阅读:
    spring注解集合
    spring工作原理理解
    Linux下mysql命令 导入 导出sql文件
    List和Set排序的实现
    LeetCode--树
    LeetCode--链表
    LeetCode--字符串
    LeetCode--贪心算法
    LeetCode--数组
    数据库编程基本练习题
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13314128.html
Copyright © 2020-2023  润新知