aspose file tools*
The moose likes Testing and the fly likes Junit4+Eclipse+Selenium RC-  Test class should have exactly one public zero-argument constructor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Junit4+Eclipse+Selenium RC-  Test class should have exactly one public zero-argument constructor" Watch "Junit4+Eclipse+Selenium RC-  Test class should have exactly one public zero-argument constructor" New topic
Author

Junit4+Eclipse+Selenium RC- Test class should have exactly one public zero-argument constructor

Sunny Saeed
Greenhorn

Joined: May 06, 2010
Posts: 4
In order to test the 2 pages of an application I have created two classes and then execute them with the 3rd class suite classes.

I am using Selenium RC with Junit 4 + Eclipse. While executing the script the test against the first class passes but while executing the 2nd class the above mentioned error is displayed.

Following are the details of the code:





I have already defined the construcotr of the class Login but the compiler still throws the error.Any help would be highly appreciated?

Regards
ES
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30293
    
150

You have the constructor public Login (Selenium selenium). The error message says you should have a zero argument one as well so you need public Login().


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sunny Saeed
Greenhorn

Joined: May 06, 2010
Posts: 4
Thank you Jeanne for your reply.

When I add public Login() {} constructor, now I receive the message 'java.lang.IllegalArgumentException: Test class can only have one constructor


Any thoughts would be highly appreciated.

Kind regards
EN


John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Sunny:

A proper JUnit 4 test class uses the default constructor, so don't create one.

John.
Sunny Saeed
Greenhorn

Joined: May 06, 2010
Posts: 4
Jeanne & John any further thoughts? I am stuck on this problem from the last few days.


Kind regards
EN
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Sunny,

Ok, I think I see the problem, and it doesn't really have anything to do with JUnit 4, Eclipse, or Selenium. You're mixing your page classes and your tests. You probably want to set your test up similar to this layout:



In general, I prefer to separate concerns by having a set of page objects that know their behavior, and use a single Selenium object, and having a set of tests that only use the page classes' interfaces. Also, since you are using Eclipse, you don't need to create a test suite, as Eclipse has a JUnit 4 test runner that will run your test and give you graphical output.

John.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Junit4+Eclipse+Selenium RC- Test class should have exactly one public zero-argument constructor