testng running on linux maven command line - java

How to run testng.xml file from maven commands in linux command line?
I am new to automation. I have created a maven project(java) using Interlij Idea for testing a web page. I can run test groups in testng.xml using Idea.
What I need now is running those test groups from the linux command line.(running the testng xml file)

You would need to download maven on linux and then AFAIK the commands shouldn't be any different so you can use the surefire plugin in your pom and specify the suiteXmlFile param to mvn test command, something like
mvn test -DsuiteXmlFile=/src/test/resources/yourxml.xml
Hope it helps..

Related

Running Java/Selenium/Cucumber tests via command line

I have a test project built in Intellij IDEA 2021.1 using Selenium, Cucumber and Maven
The project runs fine from within Intellij but now I want to call the tests from the command line and only those with a specific tag. Below is the project layout
There is only 1 feature file at present and I only want to call the scenarios with the "regression" tag from the command line.
I have run command line with Visual Studio/Selenium in the past but this is my first go with Java so any advice on how to get this started would be great.
try to execute following
mvn verify -Dcucumber.options="--tags not #ignore"
Or
mvn verify -Dcucumber.options="--tags #runme"
where #runme is a tag over Scenario or Feature.
you can try this command:
mvn clean install "-Dcucumber.options=--tags #yourtagName"

Using maven to create junit xml reports of jar

I have inherited a codebase whereby we have a maven project of component tests that use junit as the framework that runs the tests.
Everything runs OK, but the problem is that these tests must be compiled into a jar-with-dependencies so that they can be run on a standalone computer with very limited outwards connectivity (e.g does not have access to maven central).
I have managed to create a runnable jar with dependencies which I can run using junit.jar and the command line like so:
java -cp jar-with-dependencies.jar:junit.jar junit.jar org.junit.runner.JUnitCore com.testsuite.AllTests
This works but the problem is that I also need to output the junit results into XML, like maven's surefire plugin does.
My question is, can I run this jar-with-dependencies using maven such that it creates the junit xml reports?
I can successfully run the tests using exec-maven-plugin which essentially runs the previously stated command

Run a java file using JUnit in Eclipse through command terminal

I am new to automation using Appium. So while using Eclipse i created a TestSuite.java file which includes all of my test cases.I want to run this file using JUnit in eclipse through command terminal.Please help me with command in mac.
I am using macOs. I am adding some screenshots of my project.
(1) This is my project in eclipse
(2) This is my TestSuite.java file
(3) Output after running
mvn surefire:test -
DrunSuite=com.appium.automation.MobileGesturesRevised/TestSuite.class
Output: output in terminal
(4) pom.xml file
pom.xml
I think I see a pom.xml in the screen shot so you can run
mvn surefire:test -DrunSuite=com.appium.automation.MobileGesturesRevised/TestSuite.class
You can just create a new run configuration for that under the Eclipse run menu.

How to run Java-Selenium test cases through command prompt/terminal?

I am able to run my test cases through Eclipse IDE. It is not working when I try to run them through the command prompt/terminal.I get the following error.I have attached the screenshot below.
Please help me on this issue.Quick response will be of great help.Test Image
You can use maven selenium plugin to run all the integration test by using selenium
In pom.xml, add this dependency
<dependency>
<groupid>org.seleniumhq.selenium</groupid>
<artifactid>selenium-java</artifactid>
<version>2.25.0</version>
</dependency>
And in commandline, execute the test via maven
mvn clean test -Dwebdriver.base.url=http://www.example.com
You can run your scripts thru command prompt using Apache Ant. It uses build.xml which runs your testng.xml. Just the difference is that you run it from command prompt and not from eclipse or any other IDE.
You can find more info on Apache Ant & build.xml from -
http://ant.apache.org/

How to run cucmber test from command line and in jenkins

i have created a cucumber framework using Java and Maven. i execute cukesRunner.java locally in eclipse. now i wanted to execute it command line and thru jenkins. could some one please guide me.
cd to your project direct (the one containing pom.xml) and type
mvn test
Your runner class ends in Test, right? E.g. RunCukeTest.java

Categories

Resources