sujithps / powermock

Automatically exported from code.google.com/p/powermock
Apache License 2.0
0 stars 0 forks source link

Integration PowerMock and testNG Issues #224

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.created a object factory in the testNG.xml file 
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name = "EmpappSuite" verbose = "1" 
        object-factory="org.powermock.modules.testng.PowerMockObjectFactory">
  <test name = "daos">
     <classes>
         <class name = "com.DAOTest"/>
     </classes>
  </test>
</suite>
2.and had a test class with a dataprovider

@PrepareForTest(DBUtil.class)
public class DAOTest {

    private EmpDAO empDAO;

    @Mock
    private CallableStatement cs;

    @Mock
    private DBUtil dbUtil;

    @BeforeMethod
    public void setUp() throws Exception {
        empDAO= new EmpDAO();
        MockitoAnnotations.initMocks(this);
    }

    /* Custom one time tearDown() implementation after test method. */
    @AfterMethod
    public void tearDownAfterTest() throws Exception {
        empDAO = null;
        cs = null;
    }

    @Test(dataProviderClass = EmpDaoDataProvider.class,
            dataProvider = "empDaorequest")
    public void testCheckoutStatus(
            CheckoutStatusRequest request) throws Exception {
        Assert.assertNotNull(request);  
        some testmethod which will take the reqest
    }
}
3.

What is the expected output? What do you see instead?
 when i run the testNG suite i am getting the following error

java.lang.RuntimeException: Can't invoke method public void
com.DAOTest.testCheckoutStatus(the method name in that) throws
java.lang.Exception on this instance of class com.DAOTest_$$_javassist_0
due to class mismatch
    at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:629)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:557)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:711)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1013)
    at
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:137
)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:121)
    at org.testng.TestRunner.runWorkers(TestRunner.java:908)
    at org.testng.TestRunner.privateRun(TestRunner.java:617)
    at org.testng.TestRunner.run(TestRunner.java:498)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:329)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:324)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:296)
    at org.testng.SuiteRunner.run(SuiteRunner.java:201)
    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:915)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:879)
    at org.testng.TestNG.run(TestNG.java:787)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:75)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:127)

What version of the product are you using? On what operating system?
testNG 5.11, powermock-mockito-1.3.5, eclipse 3.5.1,javaassist 3.10.0
these are the jar and plugins i am using 

Please provide any additional information below.

appreciate your help if you can help me out in this issue

Original issue reported on code.google.com by reddy...@gmail.com on 11 Jan 2010 at 4:36

GoogleCodeExporter commented 8 years ago
Are you using TestNG 5.11? Could you provide the class you're trying to test as 
well? 

Original comment by johan.ha...@gmail.com on 13 Jan 2010 at 8:32

GoogleCodeExporter commented 8 years ago
Won't fix due to no response from user.

Original comment by johan.ha...@gmail.com on 10 Mar 2010 at 1:30

GoogleCodeExporter commented 8 years ago
I see the same error. 
The only difference is that I don't use a dataProvider.
@ObjectFactory
    public IObjectFactory getObjectFactory() {
        return new org.powermock.modules.testng.PowerMockObjectFactory();

    }
Just these lines produce a class mismatch error. 
I am using TestNG  5.13.1

Original comment by prama.an...@gmail.com on 13 Sep 2011 at 10:41

GoogleCodeExporter commented 8 years ago
Unfortunately PowerMock doesn't support DataProviders with TestNG. It would be 
very much appreciated if you could provide a patch. 

Original comment by johan.ha...@gmail.com on 14 Sep 2011 at 6:36

GoogleCodeExporter commented 8 years ago
I did not use a dataprovider. The problem got resolved when I updated my 
powermock version to 1.4.10

Thanks!

Original comment by prama.an...@gmail.com on 14 Sep 2011 at 4:33

GoogleCodeExporter commented 8 years ago
I have the same error using PowerMock and TestNG DataProviders. It would be 
really great if you could provide a patch for this issue.
I am using TestNG 6.3.1 and powermock 1.4.11.

Regards

Original comment by benhamid...@gmail.com on 16 Jan 2012 at 6:54

GoogleCodeExporter commented 8 years ago
I have this same issue with DataProviders in testng 6.0.1 and powermock 1.4.10

Original comment by liu.hai...@gmail.com on 12 Nov 2012 at 3:41

GoogleCodeExporter commented 8 years ago
I have this same issue with DataProviders in testng  and powermock. A patch 
would be highly appreciated.

Original comment by dce.arc...@gmail.com on 11 Aug 2013 at 1:44

GoogleCodeExporter commented 8 years ago
I have also same problems with dataproviders in testng and powermock

Original comment by christia...@gmail.com on 28 Oct 2013 at 10:16