• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

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

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author & internet detective
Posts: 41184
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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().
 
Sunny Saeed
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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


 
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sunny:

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

John.
 
Sunny Saeed
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne & John any further thoughts? I am stuck on this problem from the last few days.


Kind regards
EN
 
John de Michele
Rancher
Posts: 600
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic