This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I'm pretty new to all Maven, TestNG and the Surefire plugin that connects both.
So for, I can execute tests using the testng.xml file and groups/classes defined in the pom. Now I need to implement a factory pattern that will run all test methods for one (or more) classes.
Currently I have the following setup:
I have a test class which extends a base class to set up the environment (I'm running GUI tests with Selenium Webdriver). In the TestBase class, I prepare a number of different browsers. The Tests are grouped and my surefire plugin calls a specic group. Upon initialization of the test object containg the test methods, a factory shall provide the browsers.
Hm difficult to show that in a compact way.
But when I run my maven script the following happens:
Can't invoke public void org.test.pages.HomePageTest.testTitleMatching() throws java.lang.InterruptedException: either make it static or add a no-args constructor to your class
Currently my code looks like the following:
My parent class:
here comes my factory:
and my surefire plugin configuration:
So can anyone image what is going wrong? I read in other posts that I have to use the factory pattern (what actually do, don't I?). Wild guesses?
You could follow the second part of the error messages: "add a no-args constructor to your class"
The constructor you do have takes a parameter and I suspect that TestNG is ignoring the @Factory annotation (is that a TestNG annotation? if not, is it an annotation of a TestNG extension and if so did you properly configure the extension?)