Running Java/Selenium/Cucumber tests via command line - java

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"

Related

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 run test cases with the spring-boot framework

I downloaded and successfully ran this project:
https://github.com/spring-guides/gs-accessing-data-mongodb
I noticed it has some test cases on the file:
https://github.com/spring-guides/gs-accessing-data-mongodb/blob/master/complete/src/test/java/hello/CustomerRepositoryTests.java
To run the main application from the command line, I do:
$ ./mvnw spring-boot:run
Now, I would like to know what command do I need to execute in order to run the test cases?
Thanks!
You just need to run this command to run your tests.
mvn test
https://spring.io/guides/gs/testing-web/ can give you more information about testing.

Passing arguments to dependency eclipse plugins when using mvn-tycho

I am trying to write unit test cases for an eclipse plugin. Went through http://www.vogella.com/tutorials/EclipseTycho/article.html#run-the-build-with-the-tests and created a eclipse-test-plugin.
So, the test plugin (let's call is plugin-b) has a dependency on another plugin for which the test is written (plugin-a).
When I run mvn clean install, I can see that tycho-surefire is trying to run the tests and in the process is trying to launch plugin-a. However, plugin-a requires a set of VM args to start correctly. Am trying to pass the arguments like below:
mvn -Dabc.properties=bridge\bundles\com.blah.blah.blah.blah.bridge\abc.properties clean install
but they aren't going through to plugin-a.
Any help is greatly appreciated.
Finally figured this out:
mvn clean install -Dtycho.testArgLine="-Dabc.properties=../../bundles/com.blah.blah.blah.blah.bridge/abc.properties"
That'll pass the system properties to the test runtime.

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

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