Run a java file using JUnit in Eclipse through command terminal - java

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.

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"

IntelliJ fails on every test on a maven imported project

I imported a maven project to intellij with two modules under a parent project.
The test I want to run is made with TestNg and when I run it I just get a single line of:
java.lang.NullPointerException
No stacktrace, nothing.
If I run it from the command line it works, but only if I cd into the directory of one of the modules.
So basically thats the command that actually works:
cd server
mvn -Dtest=ConversionServiceT2 test
I'm pretty sure I didn't configure IntelliJ in the right way, but I have no idea where to start.
Here a few infos that might help:
I use the openJDK 11
I tried to set the working directory of the test config in IntelliJ to the server directory, which results in the same error
So how can I get this test (or tests in general) to run?

How to build ascidoc PDF in IntelliJ with Maven on Ubuntu Linux

My system setup is the following:
IntelliJ 2017.2
Maven 3.5.2
Java 7
Ubuntu 17.10
I have a project in IntelliJ where I want to use asciidoctor variant of asciidocs. I have created a adoc file, and now I want to create the PDF from that file.
I have tried:
mvn clean install -Pbuild-release-notes
But I cant find any PDF file.
Have a look at the POM File (pom.xml) in this asciidoctor-pdf-example project.
When you run:
mvn clean process-resources
(the maven command depends from the asciidoctor-maven-plugin configuration in the POM File)
You can run maven from the command line or from an IDE, you will get your PDF in target/generated-docs.

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/

testng running on linux maven command line

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..

Categories

Resources