AttachNotSupportedException while running jMockit tests on IBM JRE

前端 未结 6 1180
北海茫月
北海茫月 2020-12-19 16:55

I am getting the below exception when I try to run a simple jMockit/JUnit test using IBM JDK. Has anyone faced this issue? I tried given -Dcom.ibm.tools.attach.enable=

6条回答
  •  一个人的身影
    2020-12-19 17:01

    Above answer to use -javaagent is correct. If you're using maven it's a little tricky, so here is how I did it:

    1. Add the maven-dependency-plugin so you can generate absolute paths to the dependencies:
    
      org.apache.maven.plugins
      maven-dependency-plugin
      2.5.1
      
        
          getClasspathFilenames
          
             properties
          
        
      
    
    

    2. Add -javaagent to surefire plugin

    
      org.apache.maven.plugins
      maven-surefire-plugin
      2.13
      
        -javaagent:${com.googlecode.jmockit:jmockit:jar} -XX:-UseSplitVerifier
      
    
    

    3. Also, you don't have to, but I'd recommend using a relatively newer version of jmockit. This issues was detected in 1.1 (prior to September 2012 fix by @Rogério, but adding -javaagent fixes it regardless. For reference I am using the latest version available in maven central (2.5) as of this comment:

    
      com.googlecode.jmockit
      jmockit
      
      1.5
      test
    
    

提交回复
热议问题