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!!
Related
I imported several maven modules on IntelliJ IDEA by using the option File/New/Module From Existing Source. This is working fine but I'm not able to run mvn command lines on one specific module by its module name.
I was able to do it by specifying the path to the pom.xml file by using -f option:
mvn -f "path/to/pom.xml" clean
But I would like to avoid having specifying the path every time I want to run a mvn command. Is their any way to run the command by specifiying the name of the module ?
Thank you.
If you use "Run Anything" then it's possible to select module at the top right corner
You can perform maven install, maven clean etc for a complete module or sub modules of a project using top right option in IntelliJ.
Maven-->select module/submodule folder-->Plugins-->select the option:- deploy, compile, install, clean etc.
I have project files in folder:
./project/java_files/
if i go to java_files && run mvn package - all works correctly.
but how i can start same from ./project folder?
I mean without cd ./java_files of course...
you can run maven command as below, passing path to pom.xml
mvn package -f /path/to/pom.xml
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).
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.
My server runs fine from Eclipse, but I can't get it to run from command line.
Here's what I'm trying, unsuccessfully ("hp-dsat" is the name of my project and also the database name, and project folder that contains pom.xml):
# stop server
cd ~/TcServer/
./tcruntime-ctl.sh myserver/ stop
# import clean sql
dropdb hp-dsat
createdb
psql hp-dsat < ~/hp-dsat/src/main/webapp/resources/data.sql
# build project with maven (doing something wrong here?)
cd ~/hp-dsat
mvn compile
mvn package -Dmaven.test.skip=true
# move the war file to my TcServer
mv -f ~/hp-dsat/target/hp-dsat-1.0.0-BUILD-SNAPSHOT.war ~/TcServer/myserver/webapps/ROOT.war
# start the server back up
cd ~/TcServer/
./tcruntime-ctl.sh myserver/ start
The server starting, but when I visit myserver.com:8080 or myserver.com:8080/hp-dsat (second one is with the context path) it just returns nothing but a blank page.
The thing is, it works if I build the project in eclipse. I just need to figure out how to do it from command line to make a build script to use on a git hook. The server doesn't have eclipse either.
You need to use the cargo deploy plugin in maven, and also might want to look at using jenkins, or another CI server aswell.