My class (BonusDetailAction extends org.apache.struts.action.Action) doesn't have any constructors. But, according to JTest report:
Is no argument constructor is a must in the class?
I googled for the same, but I got both the answers YES and NO.
in my opinion nothing is a must or should be a must. If it makes sense to have a no-arg constructor you should have one. If you don't really need it, why should you have one? Of course some frameworks etc. force you to have no-arg constructors in practice but that's another story. If you rely on such a framework you will hardly get around such technical limitations, even if you actual business logic doesn't require a no-arg constructor. Often it is even helpful for a good application design to "document" explicit dependencies as arguments in constructors. This helps to show the dependencies and reminds you if you have too much of them
That said, I'm just not sure how this relates to testing? What does your test look like? Which version of JUnit are you using?
M K Rayapudi
Joined: Feb 19, 2007
thank you Marco,
I'm just not sure how this relates to testing?
Jtest reported this kind of suggestion, so that, I thought it is better to post in Testing. I am requesting moderators to move this thread to Java Programming (or more appropriate one).
Sorry, I just read JTest and thought of JUnit tests Now it's clearer and I think it's not wrong in this forum.
The answer to you question still stays the same: It depends No matter if you're using JTest, FindBugs, PMD, Checkstyle or anything similar you will always get hints and advices that shouldn't be used as strict rules. Unfortunately I don't know JTest so I can't tell you more about it why it would like to see a no-arg constructor for your class. Possibly there's any documentation what triggers this message?!?
subject: Is explicit no-argument constructor a must?