Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Eclipse Selenium TestNG from Windows 10 command line

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a working testNG script that I can run from inside of Eclipse.  

I want to run it from the Windows 10 command line and later from a .bat file.

A)  Can I AND do I need to compile the entire testNG blob(all the classes and other required files) to run it or can I have the command run it inside of Eclipse?

B) Inside of Eclipse I instruct it to run as a testNG script by right clicking on the project and selecting: run as testNG.  How do I do this from the Windows command line?  Now I have and it does not appear to run:
 
Sheriff
Posts: 6378
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where's the class name in that command?
 
kevin Abel
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:Where's the class name in that command?



I know how to compile a single .java file into a class using javac.  Then I can run the class file.

I don't know how to compile from inside of Eclipse.  Is there someplace in Eclipse that will let me compile or do I need to do this from outside of eclipse?

Also is there a way to add the class to my command line that I have and run the program from within Eclipse without compiling it?

Thanks,

Kevin
 
Knute Snortum
Sheriff
Posts: 6378
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I don't know how to compile from inside of Eclipse.  Is there someplace in Eclipse that will let me compile or do I need to do this from outside of eclipse?


Eclipse is probably compiling your Java code automatically.  You can check this by clicking the Project menu item and seeing if Build Automatically is checked.

Also is there a way to add the class to my command line that I have and run the program from within Eclipse without compiling it?


You can't run a Java program without compiling it.  I use JUnit to test with so I'm not up on how to use TestNG in Eclipse. However, I did find this website.
 
author & internet detective
Posts: 39624
784
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You probably want to create a jar file. Then you can run the project with all the dependencies in the classpath. Or if you use Maven/Gradle, you can created a shaded jar which is one jar with everything you need
 
kevin Abel
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute and Jeanne,
Appreciated.
Thanks,
Kevin
 
kevin Abel
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Knute,
This was the site that I used to Install TestNG into Eclipse.
Thanks,
Kevin
 
kevin Abel
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:

I don't know how to compile from inside of Eclipse.  Is there someplace in Eclipse that will let me compile or do I need to do this from outside of eclipse?


Eclipse is probably compiling your Java code automatically.  You can check this by clicking the Project menu item and seeing if Build Automatically is checked.

Also is there a way to add the class to my command line that I have and run the program from within Eclipse without compiling it?


You can't run a Java program without compiling it.  I use JUnit to test with so I'm not up on how to use TestNG in Eclipse. However, I did find this website.



Knute and Jeanne,

This is my Hierarchy:

Project Explorer
kaa1  (I think this is the project name)
-src
--kaa1 (package)
---NewTest.java
----NewTest  (It looks like the starting class but testNG does not have main class exposed)

I'm still trying to figure out if the code has been automatically compiled.  I'm not sure what to click on to check if it automatically being compiled.  

If I cannot get it to automatically compile then I'd like to know how to use Javac to compile it.  

I am looking on google but the articles I find were people ahead of me on experience and knowledge.  They were also having trouble with this topic.

Thanks,

Kevin
 
kevin Abel
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I watched a video on YouTube for how to run a TestNG script from the command line.  It is from a website called www.softwaretestingmaterial.com    How to run TestNG test using command prompt is the name of the video.

It shows putting all of the jars into the bin folder.   Using an XML file which I don't remember how to set up anymore.  Then using a line similar to:

java -cp "/opt/testng-6.8.jar:bin" org.testng.TestNG testng.xml

I watched it on my smart phone and don't know the details.

It did run the script from the command prompt so it works.  

Can anyone tell from these clues what it is doing and assist me down this path?

Thanks,

Kevin
 
Knute Snortum
Sheriff
Posts: 6378
172
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm still trying to figure out if the code has been automatically compiled.  I'm not sure what to click on to check if it automatically being compiled.  


If you have Build Automatically checked, then the class is built every time you save it.  The classes are compiled to the output folder.  By default, this "bin" under your project folder.
To check for sure what your output folder is, right-click on the project in the Project Explorer, select Build Path > Configure Build Path...  Then click the Source tab.  At the bottom you will see what your output folder is.

If you really want to see if a class has been compiled, you can use a file explorer or list command for you system.  First, find your workspace folder.  It is usually called "workspace" or "eclipse-workspace" and is in you home directory.  Then navigate to your project folder "kaa1" and then your output folder (probably "bin").  You will find folders and/or files in this folder.  Navigate to the kaa1 folder.  In it you will see NewTest.class.  Note the file modification date and time.

Please note that the above is only necessary to satisfy your curiosity.
 
That new kid is a freak. Show him this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!