Launch a test without Eclipse

Hello,

I made my own test in Java on Eclipse, and now I only can Launch my test on Eclipse.

I would like to launch my test from TestStand (or maybe from cmd), but I don’t know if it is possible with the build.gradle ?

what test did you write (JUnit \ TestNG)

sure it’s possible - here’s an example for TestNG

then from command line you can run

gradlew test

It is a JUnit Test :wink: I will read it tkanks

I really don’t understand how to launch a test on cmd, it is a gradle project, using Junit, I have to use Junit or Gradle?

Edit: I try with javac -classpath … Test_2.java, but everything on the code from Appium generate errors

Edit2: I found the Test_2.class made by Eclipse on the project file, but I can’t run it “Error: Could not find or load main class Test_2” … So How I can run my Test?

Make sure that your gradle.build contains the JUnit dependency and that gradle is configured to compile it when testing:
testCompile group: 'junit', name: 'junit', version: '4.12'

If you wish to run the whole suite of tests, use the command gradle test

Make sure that the structure of your project is as follows:
src/main/java
src/main/resources
src/test/java
src/test/resources

Otherwise, you will have to specify sourceSets in gradle.

Also, make sure that all dependencies were imported after running the build.

You should the be able to run the test using gradle.

not an elegant solution but I export the project (test) to a jar file and launch using
java.exe -jar test.jar or something similir, I cannot remember now.

you can use build.gradle to create an executable jar. You’ll need the following jar task in your build.gradle file:

jar{
from configurations.compile.collect {zipTree it}
manifest.attributes “Main-Class”: “”
}

This is what I am trying to do but I have 39errors :disappointed_relieved:
I tried also: java Test , but it said it could not load the main class …

Edit: I’m lost, where I can find my main class on an Eclipse project?

I’m trying something else, make a New JAVA (and not gradle) project, to compile and run my test class, But I have a problem with all my imports (they cannot be resolved), Is it possible to run a test as a java project?

Well, I tryed to do a Java project, it is working on Eclipse, but on the cmd I had a problem with Selenium :

you’ll need to add selenium JAR into your classpath

but I’ll recommend you to set up a Gradle \ Maven project

if you facing issues with the getting started guide, you can follow this GitHub repo

https://github.com/quinnliu/sampleGradleProject

just place your tests under the src/java/test package
and edit the build.gradle file to add Appium dependencies