-
17 votesanswersviews
扩展API内部错误:org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl
我正在尝试使用PowerMockRunner编写单元测试但是我收到以下错误: java.lang.IllegalStateException:扩展API内部错误:org.powermock.api.extension.reporter.MockingFrameworkReporterFactoryImpl无法位于类路径中 . 在Org.powermock的org.powermock.tests.... -
28 votesanswersviews
无法让Jacoco使用离线工具与Powermockito合作
鉴于Jacoco在“动态”工具时不能很好地与PowerMockito配合使用,我一直在尝试配置离线工具,希望这能为我提供适用于使用PowerMockito的类的单元测试覆盖率 . 我已经将我的pom设置如下,但我的测试课程仍然保持0%的覆盖率 . 任何帮助都非常感激,因为它让我慢慢疯狂! <project xmlns="http://maven.apache.org/POM/4.0... -
8 votesanswersviews
尝试使用PowerMock模拟静态系统类会产生VerifyError
我试图模拟JOptionPane静态方法,并陷入Java.lang.VerifyError . 所有版本都是最新版本,因为我刚下载了PowerMock for Mockito及其所有依赖项 . 我不能使用前一个问题的答案,包装类和子类包装器 - 这是我们的应用程序 . 此时我在PowerMock上投入了相当多的时间,我不想重新开始 . 有没有办法解决这个错误?我在指令中尝试了“模拟静态方法”和“模... -
3 votesanswersviews
如何在Java中模拟静态方法?
我有一个类 FileGenerator ,我正在编写一个应该执行以下操作的 generateFile() 方法的测试: 1)它应该在 BlockAbstractFactory 上调用静态方法 getBlockImpl(FileTypeEnum) 2)它应该从子类方法填充变量 blockList getBlocks() 3)它应该从最终帮助器类 FileHelper 调用一个静态方法 creat... -
1 votesanswersviews
如何使用mockito powerMock testNg模拟静态方法
@ActiveProfiles("dev") @ContextConfiguration({ "/spring-test.xml" }) public class ServiceImplTest extends AbstractTestNGSpringContextTests{} 通过使用mockito powerMock testNg模拟静态方法来编写单... -
0 votesanswersviews
我使用powermockito进行测试 . 为什么@Autowired字段未初始化
我使用powermockito进行测试 . 为什么@Autowired字段未初始化 . 这是一个示例代码 . @PrepareForTest(EntityGenerator.class)@RunWith(PowerMockRunner.class) public class LoadingEsbContractorsTaskTest { @Autowired private SrrService... -
0 votesanswersviews
Powermock在Android Studio中无法运行
apply plugin: 'com.android.application' android { compileSdkVersion 27 defaultConfig { applicationId "com.sachintitus.instafy.instafy" minSdkVersion 24 targe... -
0 votesanswersviews
JSch算法协商仅在单元测试中失败
我正在使用JSch进行sftp get操作 . 当我使用main方法运行测试时,一切都很好但是使用单元测试我遇到了问题 . 这是错误: java.lang.RuntimeException: com.jcraft.jsch.JSchException: Algorithm negotiation fail 这是失败的方法: private ChannelSftp sftpInitKeyfile(... -
9 votesanswersviews
如何测试在Kotlin中调用顶级函数的代码?
我对Kotlin很新 . 我有一个类调用顶级函数(进行http调用) . 我正在尝试为我的 class 编写单元测试而不用它去网络 . 有没有办法模拟/ powermock /拦截从我的 class 到Kotlin顶级功能的呼叫? class MyClass { fun someMethod() { // do some stuff "http:/... -
1 votesanswersviews
如何在测试期间修改静态私有字段?
我的项目使用 JUnit , Mockito , PowerMockito 来创建单元测试 . 代码如下: public class FirstController { public void doSomething() { ServiceExecutor.execute(); } } public class ServiceExecutor { pri... -
0 votesanswersviews
如何使用JUnit在Spring Boot中公共方法中模拟私有方法
我想问你几个问题,并征求你的意见: 我想测试我的公共方法(我使用Spring Boot,Mockito,JUnit): @Service public class MyClass{ public Long getClientId(List<String> nameSurname) throws AuthorizationException { Long operato... -
1 votesanswersviews
Junit中参数化测试用例出错
我试图在JUnit中编写一个参数化的测试用例 . 我的代码看起来像这样: @RunWith(Parameterized.class) @PrepareForTest({AR9DirectDebitFileWriterCustomization.class}) public class AR9DirectDebitFileWriterCustomizationTest2 extends AR3Bas... -
0 votesanswersviews
不能在junit测试中模拟对象
我有一个代码需要进行单元测试 @ManagedBean @SessionScoped public class XC implements Serializable { public void applyX(){ FacesContext context = FacesContext.getCurrentInstance(); if (!context.... -
5 votesanswersviews
使用PowerMock在Kotlin中模拟包级功能
我在Kotlin中有一个包含一些包级函数的文件 . //Logger.kt fun info(tag : String, message : String){ ... } fun error{....} 我正在测试一个调用这个kotlin文件函数的类的函数,我想嘲笑它们 . 我知道包级函数就像Java中的静态方法一样,所以我一直在考虑使用PowerMock . //MyClass: Clas...