Creating TestNG .Bat File - java

Im having trouble creating a TestNG .Bat file (After several tries I have failed to create a successfull Bat file which will in turn execute my TestNG file 'testngSides.xml'.
I wish to execute the testng file: 'testngSides.xml' via a batch file, project structure:
I also have dependencies stored within the following location 'm2':
Many thanks for your help

Sorry could not write a comment due to lack of reputation. Add dependencies in your POM.xml to run the testing.xml(you will need maven surefire plugin too).Once dependencies are set, build your maven project and run maven test through your .bat file.

Create a .bat file with following content (edit it according to your project):
set myProjectpath=”PROJECT_PATH”
cd %myProjectpath%
set classpath=%myProjectpath%\bin;%myProjectpath%\lib\*
java org.testng.TestNG %myProjectpath%\testngSides.xml
Let me know if it helps.

Related

create cucumber java testng maven executable jar project and run from command line

I created my project in Intellij idea with maven set up.
Just I want to build executable jar with complete dependencies and run through command line.
Ex: java -jar hello.jar
An example can be found in my blog post Create an executable jar from Maven
Just make sure you can run Cucumber from your main function.

Create install anywhere launcher from executable jar

I have a jar file that is being created by Spring Boot. Application runs smoothly when run by command java -jar. I want to create an install anywhere launcher with this jar file.
What I have tried is to send the Spring Boot main class (PropertiesLauncher). The issue is that calling it like this won't load the nested jars inside my executable jar and also the loader.path doesn't seems to work.
Is there a way to call the executable jar like java -jar from the install anywhere launcher?
I was thinking that another option was to create an install anywhere launcher for a script file and inside have the java -jar call. So another question will be:
How do I create an install anywhere launcher for a script file?
'execute command' step will do the trick:
Use this command line:
java -jar <path.to.jar.file>
Use EXECUTE_STDOUT, EXECUTE_STDERR and EXECUTE_EXITCODE built-in variables to catch errors and parse the jar's execution result.
Important notes:
You'll have to make sure your jar includes all of the dependencies (or at least set the classpath in the command line);
To include the dependencies within your jar using eclipse you can:
Export your project as a 'runnable jar file' and select the
'Extract/Package required libraries into generated JAR' option/s
Use Maven to build the project with dependencies; the
maven-assembly-plugin is required.
The 'execute command' will work for batch/cmd/shell scripts as well, but you'll have to make sure the scripts are extracted to a local folder such as %TEMP% or /tmp before you can use them.
Goodluck

How to run java program in maven

I have selenium maven project created. For running the tests I have to run one program that will create testNG.xml which contains list of test cases to be executed.
But for that I need to run one Java program which has dependencies on other Java programs.
You need to use the maven exec plugin.
Take a look at this http://www.mojohaus.org/exec-maven-plugin/usage.html
Check the dependency in pom.xml file.
Run command
mvn install
it will install all the dependency and create .class files.
To run java file
java -cp "define all the jar files path separated by ; or :" name of java file

How to specify Specification-Title without creating jar

When running the test phase my tests fail to the JAI requirement for the code to be run from inside a jar file that contains Specification-Title in the manifest.
Unfortunately mvn test and intellij debug do not build a a jar file (obviously) and so no manifest exists.
Is there an alternative way of setting these values?

Execute a jar inside another jar in java

I have an executable jar(mainjar) with me, i have created it using a maven project. When i pass some argument to his jar, it will execute another jar(execjar) file which is placed inside the src/main/resource of mainjar. The problem is i am not able to access the execjar inside the mainjar. Here is my folder structure of mainjar
src/main/java
MainClass
code to execute execjar- 'java -jar execjar'
src/main/resource/
execjar
The problem is when i package the mainjar using maven assembly plugin, i am not able to access the execjar inside the mainjar- nothing happens when i execute the mainjar.
Can anyone help ?
Look at the shade plugin to create an uberjar instead.
http://maven.apache.org/plugins/maven-shade-plugin/

Categories

Resources