I'm developing a selenium and TestNG project and I want to use Jenkins to run tests from .bat files.
I found some tutorials but all of them using Eclipse IDE. eg: http://learn-automation.com/selenium-integration-with-jenkins/
In Intellij IDEA I couldn't find any lib (jar files) folder and the file structure is slightly different than the Eclipse.
I was able to run through a POM.XML file but I really want to know how to build .bat file to run my testng.xml file. (From the beginning)
Compiling and Running java project from command line without any build automation tools (ANT, Maven, gradle) could get really complicated, however you can do that.
To compile and run I guess following should work.
To compile, I am not sure where class file will be generated but you can check help of javac command.
javac -classpath "[jarname with specified path]" [java filename]
This will execute the class files.
java -cp "path-to-jar/testng.jar:path_to_your_test_classes" org.testng.TestNG testng.xml
Now you can use this two command in batch file or directly use in jenkins.
However the easy and better approach will be to use Maven. There are lots of online blogs and video tutorial about how to setup up Maven project or convert existing project into maven.
Related
I have a normal project in Eclipse using Selenium and TestNG (Not Maven or Gradle).
I want to start testing running the tests via Jenkins and I realized that I can do it with an XML file that TestNG provides.
So I did it, I exported it and when running it via Eclipse, everything works.
Search online on how to run it via CMD\PowerShell and saw that the command suppose to be:
java -cp "location on the bin of the project and the location of the selenium and TestNG jars" org.testng.TestNG testng.xml
I have a bin folder of course that Eclipse builds and I created a folder named lib to put the jar files there. So this is my command:
java -cp "C:\Git\WebTesting\Bin;C:\Git\WebTesting\lib*" org.testng.TestNG testng.xml
Right away it gave me that error:
Then I realized that I didn't put the TestNG jar there, so I put it there.
Again, the same error.
Then searched online and realized that I also need to put the shellbean and Jcommander jars, so what I did is that:
java -cp "C:\git\webtesting\bin;C:\Users\User1.p2\pool\plugins\org.testng_7.3.0.r202008060316.jar;C:\Users\User1.p2\pool\plugins\com.beust.jcommander_1.78.0.jar;C:\Users\User1.p2\pool\plugins\org.apache-extras.beanshell.bsh_2.0.0.b6.jar;C:\Users\User1.p2\pool\plugins\org.yaml.snakeyaml_1.21.0.jar;" org.testng.testng testng.xml
and it still gives me the same error of not finding the Testng class!
I am already frustrated, don't know what to do.
Any help? ideas?
Thanks
I fixed the issue!
All I have to do is to put the location on the Project in $env:ProjectPath or %ProjectPath depends if you are using PowerShell or CMD. And then put the the link folder with * and also the bin folder of the project in $env:Classpath/%ClassPath%.
And finally typing $env:ProjectPath\testng.xml in the end of the command. So:
$env:ProjectPath = the path of the project (not the bin folder)
$env:ClassPath = the lib folder/*;the bin folder of the project
Java org.testng.testng $env:ProjectPath\testng.xml
I want to get started with AngularJS but I am running into problems getting the plugin to work in Eclipse. I downloaded this plugin from Github: https://github.com/sbegaudeau/AngularJS-Eclipse-Tools
When I follow the instructions in the ReadMe, I wind up with this (I also run mvn --version to make sure it is working):
And now I have a folder that looks like this:
How do I convert this Update Site into plugins that can be used in Eclipse? I looked at the file structure of the plugins already in Eclipse, and they contain Executable Jar Files. I think I should be able to do some sort of Build/Make (some command) on the files I have to get these executables.
I have a jar codebase (developed and successfully compiled in Intellij IDEA) without class files. I want to make jar with that codebase through windows batch-script only. Please help me to make the jar automatically without opening it in any IDE or any manual operation.
Thanks in advance for the help.
You generally do that using build tools like Ant, Maven. Maven is quite more popular these days.
Convert your intellij project into an Maven project like this (IntelliJ - Convert a Java project/module into a Maven project/module), and then execute call mvn clean package from your windows script to build the jar. The jar will be located under ${project.dir}/target
I have a java project in eclipse with different packages. How can I compile the project from command line in unix (bash) ? Using plain javac doesnt seem to work. For eg, in eclipse I have
src
...server
...client
...shared
And the main file that I want to run later is in the server package called server.java
You will have to add all the source paths and dependency .jar files into the compilation call. The easiest way to do this will be to get Eclipse to export an Ant build.xml for the final jar you are trying to compile. This autogenerated ant file is usually pretty messy but gives you an idea of how the project should be built.
javac -sourcepath /path/to/src -d /path/to/classes
What is the file build.xml?
I was wondering if it is a possibility to import this project in Eclipse or Netbeans using this build.xml. I tried to import the project but I get some errors since one part is created using J2ME and the other J2SE and I guess this file should be the configuration.
build.xml usually is an ant build script.
It contains information necessary to build the project to produce the desired output, be it Javadocs, a compiled project, or a JAR file.
I believe Eclipse has ant built-in, so it should be possible to execute the build.xml by choosing "Run As..." and "Ant Build".
The build.xml file, if it is an ant script, is not used to import the project into an IDE like Eclipse or Netbeans. A build script is used to build the project (or produce some desired output) rather than an mechanism for importing the project into an IDE.
As mentioned by #coobird this is an ant build file. Although IDEs such as Eclipse and Netbeans have ant support built-in, it is also possible to run ant from the command-line and this may be the simplest way to get started if the project has been well created.
See http://ant.apache.org/
for docs.
If you want to try this approach, install ant, cd to the directory with build.xml and issue
ant
Eclipse can be told to build using an Ant script, but you can also use Ant itself.
build.xml file is an Ant(Apache) script.
you can find more information on Ant & build.xml here
In java project build.xml file is used write the ant script.
And from that ant script you can generate war file and can deploy on Tomcat server