Setup build.gradle to run cucumber / junit tests via. command line against the jar file

(Cymbaline Austin) #1

Hi everyone,
I am very new to development so please excuse my awkward question.

I was tasked with setting up the build.gradle to create a fatjar file which can be ran via. command line to execute the tests.

I think I accomplished the first part of this. I setup the build.gradle file so it will create a fatjar file when ./gradlew fatJar is ran.

Now second part is how to use command line to run tests with the jar file and not meaning ./gradlew test. ./gradlew test works.

The tests are cucumber feature files but it uses a file which if select the and run it as a junit test then it will run the feature files which has a specified annotation listed in the @CucumberOptions, tags = {} . In this case my tags is @Auth.

Can running this test be done via. command line using the jar file?

Can someone provide me with a source , or the correct section(s) of the gradle docs which can help me? I’ve been hunting for this information and I’m just lost.

Thank You!

(Sterling Greene) #2

How does the fatjar fit into this? Are the tests in the fat jar?

(Cymbaline Austin) #3

Hi , The Tests should /need to be in the FatJar. I need to test to verify this . The FatJar was part of the story requirement as well as being able to run the tests using the fatJar.

I found information on creating the fatJar and here is what I have in my build.gradle. task fatJar(type: Jar) {
manifest {
attributes ‘Implementation-Version’: version,
‘Name’: “${baseName}”,
‘Main-Class’: ‘’
from { configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) } }
from sourceSets.test.output
with jar

(Cymbaline Austin) #4

Actually this morning I think I figured out how to do accomplish this.

(Raj) #5

Hi lnewportTX,

Can you please share if solution you found to run cucumber test from fat jar file. I am also facing same issue.