Constructor Error- : Test class should have exactly one public zero-argument constructor’

2,153 views
Skip to first unread message

en

unread,
Oct 27, 2011, 7:58:04 AM10/27/11
to Selenium Users
I am testing two pages of an application. As a result I have created
two different classes and run the test with the help of a Suite Class.
I am using Junit 4 and Eclipse using Java language.
Against each class I created a constructor. When executing the second
class, an error is displayed that ‘java.lang.Exception: Test class
should have exactly one public zero-argument constructor’

Following are the details of my code:
//SetupClass
package javaPackage_1710;

import org.junit.*;
import com.thoughtworks.selenium.*;
public class SetUp {
Selenium selenium;
@Test
public void setupmethodTest() throws Exception
{
selenium= new DefaultSelenium("localhost",4444,
"*googlechrome","http://tmo27.cobentdev.com");
//selenium = new DefaultSelenium ("localhost", 4444,"*firefox C:\
\Program Files (x86)\\Mozilla Firefox\\firefox.exe","http://abc.com");
selenium.start();
selenium.open("http://tmo27.cobentdev.com");
System.out.println("login page should be displayed");
selenium.waitForPageToLoad("100000");
return;
}
}

//Login Class

package javaPackage_1710;

import org.junit.*;
import com.thoughtworks.selenium.*;


public class Login {
Selenium selenium;


public Login (Selenium selenium){
this.selenium=selenium;
}



@Test
public void loginfunctiontest ()
{
Login Login = new Login(selenium);
Login.login("best01");
Login.password("admin");

}

public void login (String username)
{
selenium.type("xpath=//input[@name='txtName']", username);

}
public void password(String password)
{
selenium.type("xpath=//input[@name='txtPassword']", password);
selenium.click("xpath=//input[@name='ibSubmit' and
@value='SUBMIT']");

}

}

package javaPackage_1710;

import org.junit.runners.Suite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({SetUp.class,Login.class})

public class MyTestSuite {

}

Any help would be highly appreciated.

Kind regards
EN
Reply all
Reply to author
Forward
0 new messages