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

**URL:** <https://discuss.gradle.org/t/setup-build-gradle-to-run-cucumber-junit-tests-via-command-line-against-the-jar-file/23953>\
**Category:** Help/Discuss\
**Created:** [August 31, 2017, 11:52pm UTC](https://discuss.gradle.org/t/setup-build-gradle-to-run-cucumber-junit-tests-via-command-line-against-the-jar-file/23953 "2017-08-31T23:52:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lnewportTX](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lnewportTX](https://discuss.gradle.org/u/lnewportTX)\
**Post date:** [August 31, 2017, 11:52pm UTC](https://discuss.gradle.org/t/setup-build-gradle-to-run-cucumber-junit-tests-via-command-line-against-the-jar-file/23953/1 "2017-08-31T23:52:09Z")

</div>

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 RunFeatureTests.java file which if select the RunFeatureTests.java 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!

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [September 1, 2017, 1:00am UTC](https://discuss.gradle.org/t/setup-build-gradle-to-run-cucumber-junit-tests-via-command-line-against-the-jar-file/23953/2 "2017-09-01T01:00:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lnewportTX](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lnewportTX](https://discuss.gradle.org/u/lnewportTX)\
**Post date:** [September 1, 2017, 12:50pm UTC](https://discuss.gradle.org/t/setup-build-gradle-to-run-cucumber-junit-tests-via-command-line-against-the-jar-file/23953/3 "2017-09-01T12:50:26Z")

</div>

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’: ‘com.earlywarning.ck.TestMainClass’  
}  
from { configurations.testCompile.collect { it.isDirectory() ? it : zipTree(it) } }  
from sourceSets.test.output  
with jar  
}

---

<div class="post-metadata">

**Author:** ![lnewportTX](https://avatars.discourse-cdn.com/v4/letter/l/48db29/32.png) [@lnewportTX](https://discuss.gradle.org/u/lnewportTX)\
**Post date:** [September 1, 2017, 4:56pm UTC](https://discuss.gradle.org/t/setup-build-gradle-to-run-cucumber-junit-tests-via-command-line-against-the-jar-file/23953/4 "2017-09-01T16:56:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Rajendra09](https://avatars.discourse-cdn.com/v4/letter/r/58f4c7/32.png) [@Rajendra09](https://discuss.gradle.org/u/Rajendra09)\
**Post date:** [December 4, 2017, 11:35am UTC](https://discuss.gradle.org/t/setup-build-gradle-to-run-cucumber-junit-tests-via-command-line-against-the-jar-file/23953/5 "2017-12-04T11:35:13Z")

</div>

Hi lnewportTX,

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