-
Notifications
You must be signed in to change notification settings - Fork 4
FAQ
Known issues:
If you facing any issue with a message about no definition for class com.sun.tools.attach.AgentInitializationException (there is an example stack trace below) during running tests in your idea then you should attach a certain jar file. Your JDK installation should contain this jar in a directory {JDK_INSTALLATION_DIR}/lib/tools.jar. Below there is a description of how to resolve such an issue in the IntelliJ idea.
java.lang.NoClassDefFoundError: com/sun/tools/attach/AgentInitializationException at com.github.starnowski.bmunit.extension.junit4.rule.BMUnitMethodRule$3.evaluate(BMUnitMethodRule.java:92) at com.icegreen.greenmail.junit.GreenMailRule$1.evaluate(GreenMailRule.java:53) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:84) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:252) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:94) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61) at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:191) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68) at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70) Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AgentInitializationException at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 21 more
If you observe such error in your Intellij:
Then you need to from the main menu, select "File->Project Structure..."

In the "Libraries" section, add a new Java library:

Find the tool.jar library file in the lib subdirectory of your JDK installation directory. Usually, the JDK installation directory is the same directory where the JAVA_HOME environment variable is pointing.

Select all modules which contain tests with the "BMUnitMethodRule"

After applying configuration changes the "AgentInitializationException" exception should not occur.