Closed Vengat closed 4 years ago
@RunWith(DataProviderRunner.class) @PrepareForTest({ CertificateManagementService.class, CertificateManagementDao.class, LoggerFactory.class, org.slf4j.LoggerFactory.class }) @PowerMockIgnore({ "java.net.ssl", "javax.security.auth.x500.X500Principal" }) public class CertificateManagementServiceTest {
@Rule
public PowerMockRule rule = new PowerMockRule();
I see the same exception when running from mvn command line
java.lang.IllegalStateException: Cannot clear JavaAgentClassRegister. Set method has not been called. at org.powermock.api.extension.agent.JavaAgentFrameworkRegisterImpl.clear(JavaAgentFrameworkRegisterImpl.java:41) at org.powermock.modules.junit4.rule.PowerMockStatement.clearFrameworkAgentClassRegister(PowerMockRule.java:84) at org.powermock.modules.junit4.rule.PowerMockStatement.evaluate(PowerMockRule.java:78) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
Unfortunately, I have not a lot experience with PowerMock, yet. A little reproducer as Git repository would really help me @Vengat. Would that be possible?
Edit: By the way, before using power mock I think it is better to prefer refactor the code to get it testable without bytecode manipulating frameworks. That's even the opinion of some powermock maintainers such that they just suggest to use powermock as the last option...
@Vengat any further feedback on this, otherwise I will close the issue. Thanks.
Andreas, sorry could'nt get back to you. Will elaborate today.
On Sat, Sep 21, 2019, 3:13 AM Andreas Schmid notifications@github.com wrote:
@Vengat https://github.com/Vengat any further feedback on this, otherwise I will close the issue. Thanks.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TNG/junit-dataprovider/issues/120?email_source=notifications&email_token=AAZP2Q4FGWIPSFQXEJVRGQ3QKU7YHA5CNFSM4IGBW242YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD7H6NMI#issuecomment-533718705, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZP2QZIF226GHG56PET2ZLQKU7YHANCNFSM4IGBW24Q .
@Vengat: Any news on this?
I will close this issue while waiting for response, but don't hesitate to reopen if you have any further information for me to reproduces it.
Sorry for the late reply, Andreas...I had to move on with TestNG. Anyways I will try to recreate the bug, if I get some free time.
Again apologies for the late reply.
On Sat, Dec 14, 2019 at 6:03 PM Andreas Schmid notifications@github.com wrote:
@Vengat https://github.com/Vengat: Any news on this?
I will close this issue while waiting for response, but don't hesitate to reopen if you have any further information for me to reproduces it.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/TNG/junit-dataprovider/issues/120?email_source=notifications&email_token=AAZP2Q3AFPWIOIDU4CEB2GDQYTHBNA5CNFSM4IGBW242YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEG4BSMQ#issuecomment-565713202, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZP2QYBD4HFSYITIZSY2WLQYTHBNANCNFSM4IGBW24Q .
Overview
Unable to use DataProviderRunner with PowerMockRule as well as PowerMockDelegator. I need to mock static and final classes/methods. I am not able to get DataProvider to work with this combination when run as mvn test with PowerMockRule declared.
Eclipse run these tests, fine if I remove the PowerMockRule, when run as Junit tests but when I invoke the tests from the Maven command nothing happens.
TODO: Replace the following bullet points with your issue description. Junit 4.12 DataProvider 1.13.1
Deliverables