Running a single test with invoker plugin - maven

Following is the directory structure for my integration tests
/src/it/first-test
-->my-test
-->build.log
-->inoker.properties
-->pom.xml
-->verify.groovy
When I try to run a single integration tests as described https://maven.apache.org/plugins/maven-invoker-plugin/usage.html. It gives a message that ' No projects were selected for execution' Here is the command I used to invoke the project
/src/main> mvn invoker:run -Dinvoker.test=first-test/my-test*
How should I make sure the test is run?

It looks like you misunderstood the docs how to structure your integration tests. The first integration test should be located /src/it/first-test the second integration test should be located /src/it/second-test which means your folder my-test should be removed...Furthermore you should start the integration test from your project root and not by mvn invoker:run you should use mvn verify -Dinvoker.test=first-test instead...

It looks like you are executing it from src/main. Try it again from the root of the project (where the pom.xml is located).

Related

What is relation of Cucumber feature files with Test Runner file in Karate?

I have found if I only add karate core dependency and run my tests, they run fine and report is generated.
So what is importance of making a test runner class? I can run my karate tests without it as well. Kindly explain!
With Karate runner class , you can use #KarateOptions to include or exclude feature files that you want to run eg #KarateOptions(features = "classpath:FeatureFiles/test.feature" , tags = "~#Smoke") will run all feature files other than the one having #Smoke tag .
How to pass parameter to run Karate tests from cmd/terminal as maven project
If we want to run only 'Smoke' tests then code can be written as :
Open cmd/terminal
cd 'karate project path'
mvn test -Dkarate.options="--tags #Smoke classpath:FeatureFiles"

Gradle Cucumber test generates build folder on daemon instead of project directory

I have a test automation project where basically I run cucumber test via gradle task. What's weird is that the build folder is generated on .daemon folder instead of the project directory. E.g.
/Users/my_user/.gradle/daemon/5.6
Whereas it should be on:
/Users/my_user/my_project/build
Weirdly enough this seems to only happen on my local. Is there anything I might have missed on setting up the gradle?

Maven project execute without ide

I do a selenium test using Maven. I have more than 20 test classes. How do I export and run them without ide ?
I am also using the POM structure.
Simply open terminal/cmd, navigate to you project directory and use maven command:
mvn clean test
clean — delete target directory
test — run tests
If you want to specify which exactly class you want to run (no all like above) you can run a -Dtest parameter like suggested:
mvn clean -Dtest=testClass install
First navigate to folder where your project's pom.xml is located.
cd DirectoryWherePOMisLocated
then execute below command,
mvn clean -Dtest=classNameWhichYouWantToExecute install
If you want to execute multiple classes just separate them with , in -Dtest argument.
Hope this helps!!

How to Build a maven project using script file?

I have created a maven project in STS.I completed the development and testing code for my project.If now I want to run or build this project, then I have to do the following
Right click on the project-->Run as-->Run on Server (or)
Right click on the project-->Run as-->Maven Build
If I want to run the test code then
Right click on the class file-->Run as-->Run JUnit
But I want to create a text file I mean script file to run all these commands when I run this script file from the cmd prompt. I have found out on a web site that I should create a PowerShell file, So I don't cognize how to compose a script file like this, is there any example file for it ?
Please, anybody can help me
You can just run mvn clean install on your project root folder (i.e. where your pom.xml file is) in cmd prompt. This command will trigger your project default build lifecycle covering a number of build phases including:
validate
compile
test
package
integration-test
integration
verify
install
During these build phases, Maven will validate and compile your project, run tests (if any) against your codes, package the resultant binaries into say, a JAR file, run integration tests (if any) against your JAR, verify it, and then install the verified package to your local .m2 repository.
If you really want a script, then just add mvn clean install to your batch file.

how can I run maven test case

I have create a small web project using maven.so I want to add test classes and directory to that project.I'm using eclipse as IDE my source folder is "src/main/java" I added test source folder "src/test/java" and added one test class with one test selenium casetry to compile and run it using "mvn test" command,But console only shows "run 0 failure 0 error 0 skip 0",Can any one explain me how to run my testcases properly,is there any configurations to do ?
thnxx
mvn test runs unit tests without additional configuration, but for selenium you need to refer to selenium maven plugin.
If your tests are not in the default location src/test/java, you can specify the alternate location as follows:
<testSourceDirectory>${basedir}/my/alternate/location</testSourceDirectory>

Resources