【问题标题】:MUnit error : A JNI error has occurred, please check your installation and try againMUnit 错误:发生 JNI 错误,请检查您的安装并重试
【发布时间】:2016-12-25 01:25:17
【问题描述】:

我按照教程安装MUnit插件作为这个页面:https://docs.mulesoft.com/munit/v/1.1.1/using-munit-in-anypoint-studio

但是,当我运行一个空的测试用例时,AnyPoint 会返回一个错误:发生 JNI 错误,请检查您的安装并重试。

在控制台中,我看到异常为:

线程“main”中的异常 java.lang.NoClassDefFoundError: org/mule/munit/runner/mule/result/notification/NotificationListener at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods (Unknown Source) at java.lang.Class.privateGetMethodRecursive(Unknown Source) at java.lang.Class.getMethod0(Unknown Source) at java.lang.Class.getMethod(Unknown Source) at sun.launcher.LauncherHelper.validateMainClass(Unknown来源)在 sun.launcher.LauncherHelper.checkAndLoadMain(未知来源) 引起:java.lang.ClassNotFoundException:org.mule.munit.runner.mule.result.notification.NotificationListener at java.net.URLClassLoader.findClass(未知来源)在 java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 7 更多

请帮忙看看是什么问题。

提前致谢。

【问题讨论】:

  • 您好,MUnit 空测试不是有效构造,与空流无效一样。也就是说,一个空的 MUnit 测试不应该抛出这样的错误,我无法重现它。你能分享一个例子来重现吗?此外,如果您在从 Anypoint Studio 或从 maven 命令行运行时遇到此错误,以及最后您使用的是哪个操作系统,了解以下信息也会有很大帮助:Mule 版本、MUnit 版本。干杯!

标签: installation mule anypoint-studio munit


【解决方案1】:

我在这里假设一些事情:1)您正在使用 Anypoint Studio 和 2)您的项目是 Mavenized

1) 安装 MUnit: 转到 Anypoint Studio 中的帮助菜单,然后单击 安装新软件 。在 Work With 列中输入 http://studio.mulesoft.org/r4/munit 并添加。

完成后,我们需要将此 MUnit 添加到 Maven 路径。

2) 添加到路径: 在您的项目资源管理器中转到 src/test/munit 并右键单击它。从下拉菜单中选择 Munit 并选择 Configure MUnit Maven Support

在此之后,Maven 将自动触发构建,并且将下载所有必要的文件,包括您在问题中提到的文件。

希望这会有所帮助!

【讨论】:

    【解决方案2】:

    您可能在运行时没有 MUnit 运行器。您可以通过将 munit runner 添加到我的 pom.xml 来解决此问题。

    依赖关系

    <dependency>
    <groupId>com.mulesoft.munit</groupId>
    <artifactId>mule-munit-support</artifactId>
    <version>${mule.munit.support.version}</version>
    <scope>test</scope>
    

    <dependency>
    <groupId>com.mulesoft.munit</groupId>
    <artifactId>munit-runner</artifactId>
    <version>${munit.version}</version>
    <scope>test</scope>
    

    插件

    <plugin>
                <groupId>com.mulesoft.munit.tools</groupId>
                <artifactId>munit-maven-plugin</artifactId>
                <version>${munit.version}</version>
                <executions>
                    <execution>
                        <id>test</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <coverage>
                        <runCoverage>true</runCoverage>
                        <formats>
                            <format>html</format>
                        </formats>
                    </coverage>
                </configuration>
            </plugin>
    

    还记得将你的 munit 源添加为 maven 测试资源,例如,

    <testResources>
            <testResource>
                <directory>src/test/munit</directory>
            </testResource>
        <testResource>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources
    

    【讨论】:

      猜你喜欢
      • 2020-01-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-05
      相关资源
      最近更新 更多