Hi Group : TestNG : get this exception : "Cannot instantiate class " when running testNG program

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Hi Group : TestNG : get this exception : "Cannot instantiate class " when running testNG program

Rekha S
Hi 
Im a new user of TestNG . When i run a test ,i get this exception 

Cannot instantiate class testSp2
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)


Can anyone help?


thanks
RS

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hi Group : TestNG : get this exception : "Cannot instantiate class " when running testNG program

Krishnan Mahadevan
TestNG is NOT able to find a class called "testSp2"

Please show us your code and tell us how are you running your test ?

Thanks & Regards
Krishnan Mahadevan

"All the desirable things in life are either illegal, expensive, fattening or in love with someone else!"
My Scribblings @ http://wakened-cognition.blogspot.com/


On Thu, May 9, 2013 at 1:43 AM, Rekha S <[hidden email]> wrote:
Hi 
Im a new user of TestNG . When i run a test ,i get this exception 

Cannot instantiate class testSp2
at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)


Can anyone help?


thanks
RS

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/testng-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Hi Group : TestNG : get this exception : "Cannot instantiate class " when running testNG program

jyothi
This post has NOT been accepted by the mailing list yet.
This post was updated on .
I am getting the below error:
Error:
org.testng.TestNGException:
Cannot instantiate class com.pep.franchise.com.TransactionsDataDriven
        at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:38)
        at org.testng.internal.ClassHelper.createInstance1(ClassHelper.java:387)
        at org.testng.internal.ClassHelper.createInstance(ClassHelper.java:299)
        at org.testng.internal.ClassImpl.getDefaultInstance(ClassImpl.java:110)
        at org.testng.internal.ClassImpl.getInstances(ClassImpl.java:186)
        at org.testng.internal.TestNGClassFinder.<init>(TestNGClassFinder.java:120)
        at org.testng.TestRunner.initMethods(TestRunner.java:409)
        at org.testng.TestRunner.init(TestRunner.java:235)
        at org.testng.TestRunner.init(TestRunner.java:205)
        at org.testng.TestRunner.<init>(TestRunner.java:160)
        at org.testng.remote.RemoteTestNG$1.newTestRunner(RemoteTestNG.java:141)
        at org.testng.remote.RemoteTestNG$DelegatingTestRunnerFactory.newTestRunner(RemoteTestNG.java:271)
        at org.testng.SuiteRunner$ProxyTestRunnerFactory.newTestRunner(SuiteRunner.java:561)
        at org.testng.SuiteRunner.init(SuiteRunner.java:157)
        at org.testng.SuiteRunner.<init>(SuiteRunner.java:111)
        at org.testng.TestNG.createSuiteRunner(TestNG.java:1299)
        at org.testng.TestNG.createSuiteRunners(TestNG.java:1286)
        at org.testng.TestNG.runSuitesLocally(TestNG.java:1140)
        at org.testng.TestNG.run(TestNG.java:1057)
        at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:111)
        at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:204)
        at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:175)
Caused by: java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
        at org.testng.internal.ObjectFactoryImpl.newInstance(ObjectFactoryImpl.java:29)
        ... 21 more
Caused by: java.lang.NullPointerException
        at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:212)
        at org.openqa.selenium.support.ui.FluentWait.<init>(FluentWait.java:102)
        at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:71)
        at org.openqa.selenium.support.ui.WebDriverWait.<init>(WebDriverWait.java:45)
        at com.pep.franchise.com.TransactionsDataDriven.<init>(TransactionsDataDriven.java:28)
        ... 26 more



Code:
package com.abc.com;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.safari.SafariDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import junit.framework.Assert;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

public class TransactionsDataDriven
{
        WebDriver driver;
       
        WebDriverWait wait = new WebDriverWait(driver, 60);
       
        @Test(dataProvider = "testdata")
        public void transactions() throws InterruptedException
        {
                driver = new SafariDriver();
                driver.get("www.google.com");
                Thread.sleep(2000);

               
        }
       
       
        @DataProvider(name = "testdata")
        public Object [][] readExcel() throws BiffException, IOException, InterruptedException {
               
                File f= new File(".//resource//TestData.xlsx");
               
                Workbook w = Workbook.getWorkbook(f);
                Sheet s = w.getSheet("Sheet1");
                int rows = s.getRows();
                int columns = s.getColumns();
               
                String inputData [][] = new String [rows] [columns];
                for (int i=0; i<rows; i++){
                        for (int j=0; j<columns; j++){
                        Cell c =s.getCell(j, i);
                        inputData [i][j] = c.getContents();
                       
                        }
                }
               
                return inputData;
               
        }

       

       
       
}



<b>POM
 <dependencies>
   
   
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>2.53.1</version>
        </dependency>
       
       
        <dependency>
    <groupId>net.sourceforge.jexcelapi</groupId>
    <artifactId>jxl</artifactId>
    <version>2.6.12</version>
        </dependency>
       
        <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.7</version>
        <scope>test</scope>
        </dependency>
   
   
  </dependencies>
Loading...