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

    <legend id='PcIj8'><style id='PcIj8'><dir id='PcIj8'><q id='PcIj8'></q></dir></style></legend>

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

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

        PowerMock 抛出 NoSuchMethodError (setMockName)

        时间:2023-05-29
          <tbody id='ZLOyI'></tbody>

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

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

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

                  本文介绍了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)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

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

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

                      <legend id='kJzNi'><style id='kJzNi'><dir id='kJzNi'><q id='kJzNi'></q></dir></style></legend>