Reputation: 149
I have written my own test framework. It is written purely in Java (it has main()
) as a Maven project and it is using Selenium WebDriver.
I would like to integrate this with Jenkins so that the tests are run after deployment, is it possible?
I only found that Selenium/java tests can be integrated with Jenkins when using TestNG or JUnit. What about main()
method?
Has anyone ever done that? Do you know if this is even possible?
Upvotes: 1
Views: 227
Reputation: 16
Yes, it is possible. Below is the simple way 1. Generate jar 2. create job in jenkins and add a step as execute batch command 3. in the batch command step, execute the jar file "java -jar "
Upvotes: 0
Reputation: 8531
You do not necessarily need a framework to run your tests. You can use maven to run your main method.
In the build section use the exec goal for maven
clean compile exec:java -Dexec.mainClass="<package.class>" -Dexec.args="$args"
Upvotes: 1
Reputation: 5466
It should be possible - Can a main() method of class be invoked in another class in java
Rather than invoking the main method in a deployed application,
Try the following
1) Put the logic inside your main method into a separate method, say myTest() in the same class, and invoke the method from the main method. This step will be assisting you in your local environment Testing.
Now we have more options to invoke the test method myTest()
Some of them
a) Create a servlet and invoke the method myTest() from the servlet.
b) Create a Quartz Scheduler and invoke the method myTest().
If you still need the main method, then better go for creating a executable jar, rather than deploying it as a web application.
Ref: Deploying Java Application(Main Class) over Weblogic
Upvotes: 0