0

나는 안드로이드 테스트를 자동화하기 위해 maven 프로젝트를 만들었습니다. 비공개 필드를 테스트하기 위해 junit-addons를 추가 할 때까지 제대로 작동했습니다. 나는 치어 파일에 다음 종속성을 추가 : Android Test Maven Plugin throw 및 오류 : java.lang.NoClassDefFoundError : junitx.util.PrivateAccessor

<dependency> 
     <artifactId>junit-addons</artifactId> 
     <groupId>junit-addons</groupId> 
     <version>1.4</version> 
     <scope>provided</scope> 
</dependency> 

는 그 다음 날 PrivateAccessor을 사용하고 각 테스트 케이스에 대한 오류를 제공합니다.
java.lang.NoClassDefFoundError: junitx.util.PrivateAccessor 

내가 <scope>provided</scope>를 제거하고 프로젝트를 실행하지만 나에게 다음과 같은 오류를 제공합니다 : 오류가 울부 짖는 소리처럼

trouble processing "javax/xml/parsers/DocumentBuilder.class": 

Ill-advised or mistaken usage of a core class (java.* or javax.*) 
when not building a core library. 

This is often due to inadvertently including a core library file 
in your application's project, when using an IDE (such as 
Eclipse). If you are sure you're not intentionally defining a 
core class, then this is the most likely explanation of what's 
going on. 

However, you might actually be trying to define a class in a core 
namespace, the source of which you may have taken, for example, 
from a non-Android virtual machine project. This will most 
assuredly not work. At a minimum, it jeopardizes the 
compatibility of your app with future versions of the platform. 
It is also often of questionable legality. 

If you really intend to build a core library -- which is only 
appropriate as part of creating a full virtual machine 
distribution, as opposed to compiling an application -- then use 
the "--core-library" option to suppress this error message. 

If you go ahead and use "--core-library" but are in fact 
building an application, then be forewarned that your application 
will still fail to build or run, at some point. Please be 
prepared for angry customers who find, for example, that your 
application ceases to function once they upgrade their operating 
system. You will be to blame for this problem. 

If you are legitimately using some code that happens to be in a 
core package, then the easiest safe alternative you have is to 
repackage that code. That is, move the classes in question into 
your own package namespace. This means that they will never be in 
conflict with core system classes. JarJar is a tool that may help 
you in this endeavor. If you find that you cannot do this, then 
that is an indication that the path you are on will ultimately 
lead to pain, suffering, grief, and lamentation. 

어떤 도움을 주시면 감사하겠습니다.

답변

0

해결책을 직접 찾았습니다. junit-addons에서 3 개의 다른 라이브러리에 의존하기 때문에 오류가 발생했습니다. 나는이 라이브러리들을 필자의 의존성에서 제외시켰다.

<dependency> 
      <groupId>junit-addons</groupId> 
      <artifactId>junit-addons</artifactId> 
      <version>1.4</version> 
      <exclusions> 
       <exclusion> 
        <groupId>junit</groupId> 
        <artifactId>junit</artifactId> 

       </exclusion> 

       <exclusion> 
        <groupId>xerces</groupId> 
        <artifactId>xercesImpl</artifactId> 

       </exclusion> 

       <exclusion> 
        <groupId>xerces</groupId> 
        <artifactId>xmlParserAPIs</artifactId> 

       </exclusion> 
      </exclusions> 
     </dependency> 
:

나는하여 JUnit을-애드온의 실행 종속에 다음 <scope>privided</scope>를 제거하고 추가해야