在IntelliJ中解决"package org.powermock.modules.junit4不存在"的问题,可以按照以下步骤进行操作:
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>版本号</version>
<scope>test</scope>
</dependency>
请注意,这只是一个示例依赖项,确保使用适合您项目的正确版本号。
如果按照上述步骤操作后仍然出现"package org.powermock.modules.junit4不存在"的问题,可能是由于其他配置或依赖项冲突引起的。您可以尝试以下进一步的解决方法:
希望以上解决方法能帮助您解决"package org.powermock.modules.junit4不存在"的问题。如果您需要更详细的帮助或有其他问题,请提供更多上下文信息,以便我们能够更准确地帮助您解决问题。
import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.aop.framework.Advised;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.util.ReflectionTestUtils;
@RunWith(PowerMockRunner.class)
@PrepareForTest( { PaymentReconService.class })
@PowerMockIgnore(“org.apache.log4j.*”)
public class PaymentGatherServiceTest extends PaymentServiceTestBase {
@Autowired
private GatherService gatherResultService;
@Autowired
private PaymentBaseDAO baseDAO;
/**
* 测试正常postback
*/
public void testPaymentSucc() {
PaymentReconService mock = mock();
Long pbId = 10004L;
String pbStatus = PaymentBaseEO.PB_STATUS_GATHER_SUCC;
BigDecimal succAmount = new BigDecimal(“99.3”);
try {
GatherOrderRO ro = gatherResultService.processPaymentGather(pbId, pbStatus, succAmount, succAmount);
assertNotNull(ro);
} catch (SystemException e) {
fail(e.getLocalizedMessage());
} catch (BusinessException e) {
fail(e.getBusinessCode());
}
EasyMock.verify(mock);
}
/**
* MOCK PaymentReconService实现
* @return
*/
private PaymentReconService mock() {
PaymentReconRO mockRO = new PaymentReconRO(PaymentReconRO.Status.SUCESS, “OK”);
PaymentReconService mock = EasyMock.createMock(PaymentReconServiceImpl.class);
EasyMock.expect(mock.paymentSuccessRecon(EasyMock.anyObject(Long.class))).andReturn(mockRO);
EasyMock.replay(mock);
//这里把依赖的数据注进去
ReflectionTestUtils.s
领取专属 10元无门槛券
手把手带您无忧上云