<i id='f3syl'><tr id='f3syl'><dt id='f3syl'><q id='f3syl'><span id='f3syl'><b id='f3syl'><form id='f3syl'><ins id='f3syl'></ins><ul id='f3syl'></ul><sub id='f3syl'></sub></form><legend id='f3syl'></legend><bdo id='f3syl'><pre id='f3syl'><center id='f3syl'></center></pre></bdo></b><th id='f3syl'></th></span></q></dt></tr></i><div id='f3syl'><tfoot id='f3syl'></tfoot><dl id='f3syl'><fieldset id='f3syl'></fieldset></dl></div>

    • <bdo id='f3syl'></bdo><ul id='f3syl'></ul>

    1. <small id='f3syl'></small><noframes id='f3syl'>

      <tfoot id='f3syl'></tfoot><legend id='f3syl'><style id='f3syl'><dir id='f3syl'><q id='f3syl'></q></dir></style></legend>

    2. PowerMock 抛出 NoSuchMethodError (setMockName)

      时间:2023-10-01
        <bdo id='Cl7bm'></bdo><ul id='Cl7bm'></ul>
                <i id='Cl7bm'><tr id='Cl7bm'><dt id='Cl7bm'><q id='Cl7bm'><span id='Cl7bm'><b id='Cl7bm'><form id='Cl7bm'><ins id='Cl7bm'></ins><ul id='Cl7bm'></ul><sub id='Cl7bm'></sub></form><legend id='Cl7bm'></legend><bdo id='Cl7bm'><pre id='Cl7bm'><center id='Cl7bm'></center></pre></bdo></b><th id='Cl7bm'></th></span></q></dt></tr></i><div id='Cl7bm'><tfoot id='Cl7bm'></tfoot><dl id='Cl7bm'><fieldset id='Cl7bm'></fieldset></dl></div>
                <legend id='Cl7bm'><style id='Cl7bm'><dir id='Cl7bm'><q id='Cl7bm'></q></dir></style></legend>

                <small id='Cl7bm'></small><noframes id='Cl7bm'>

                  <tbody id='Cl7bm'></tbody>

              • <tfoot id='Cl7bm'></tfoot>
              • 本文介绍了PowerMock 抛出 NoSuchMethodError (setMockName)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试使用 PowerMockito 模拟构造函数,但每次运行测试时都会出现以下错误:

                I'm trying to mock a constructor using PowerMockito but every time I run the test I get the following error:

                java.lang.NoSuchMethodError: org.mockito.internal.creation.MockSettingsImpl.setMockName(Lorg/mockito/mock/MockName;)Lorg/mockito/internal/creation/settings/CreationSettings;
                at org.powermock.api.mockito.internal.mockcreation.MockCreator.createMethodInvocationControl(MockCreator.java:107)
                at org.powermock.api.mockito.internal.mockcreation.MockCreator.mock(MockCreator.java:60)
                at org.powermock.api.mockito.internal.expectation.DefaultConstructorExpectationSetup.createNewSubstituteMock(DefaultConstructorExpectationSetup.java:105)
                at org.powermock.api.mockito.internal.expectation.DefaultConstructorExpectationSetup.withAnyArguments(DefaultConstructorExpectationSetup.java:71)
                

                我的项目中有以下 PowerMock 依赖项:

                I have the following PowerMock dependencies in my project:

                • org.powermock:powermock-module-junit4:1.5.6
                • org.powermock:powermock-mockito-release-full:1.5.6

                我已经跟踪了我的项目的依赖树并修复了冲突,以便 mockito-all:1.9.5 被包含在构建中.

                I've traced the dependency tree of my project and fixed conflicts so that mockito-all:1.9.5 gets included in the build.

                推荐答案

                我的问题是由于我的项目(传递)依赖项中的 javassist 版本冲突.我所做的是搜索将旧版本的 javassist 放入构建中的所有依赖项,然后排除它们.例如:

                My problem was due to conflicting versions of javassist in my project's (transitive) dependencies. What I did was search for all dependencies that put old version of javassist in the build, then exclude them. For example:

                <dependency>
                    <groupId>org.hibernate</groupId>
                    <artifactId>hibernate-entitymanager</artifactId>
                    <version>3.5.1-Final</version>
                    <scope>provided</scope>
                    <exclusions>
                        <exclusion>
                            <groupId>javassist</groupId>
                            <artifactId>javassist</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
                

                这篇关于PowerMock 抛出 NoSuchMethodError (setMockName)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:Mockito thenReturn 返回相同的实例 下一篇:使用 Mockito 在另一个类中模拟一个类方法

                相关文章

                最新文章

              • <i id='jfeQR'><tr id='jfeQR'><dt id='jfeQR'><q id='jfeQR'><span id='jfeQR'><b id='jfeQR'><form id='jfeQR'><ins id='jfeQR'></ins><ul id='jfeQR'></ul><sub id='jfeQR'></sub></form><legend id='jfeQR'></legend><bdo id='jfeQR'><pre id='jfeQR'><center id='jfeQR'></center></pre></bdo></b><th id='jfeQR'></th></span></q></dt></tr></i><div id='jfeQR'><tfoot id='jfeQR'></tfoot><dl id='jfeQR'><fieldset id='jfeQR'></fieldset></dl></div>

                  <small id='jfeQR'></small><noframes id='jfeQR'>

                    <bdo id='jfeQR'></bdo><ul id='jfeQR'></ul>

                  1. <legend id='jfeQR'><style id='jfeQR'><dir id='jfeQR'><q id='jfeQR'></q></dir></style></legend>
                    <tfoot id='jfeQR'></tfoot>