Error package org.junit.Assert is displayed on running the project with graddle

First of all let me tell you am a new in this . Actually i am having Cucumber framwork with graddle and using Webdriver to automate.

I have created some test cases and are running fine on local machine. but when i am running with graddle through command prompt an error is coming like error: package org.junit does not exist.

I am having the build.graddle file like this

apply plugin: ‘java’ version = ‘1.0’

repositories {


maven {

url “

url “

} }

sourceCompatibility = 1.6 targetCompatibility = 1.6

configurations {

cucumberRuntime {

extendsFrom testRuntime

} }

task test(overwrite: true) {

dependsOn assemble, processTestResources, compileTestJava

doLast {

javaexec {

main = “org.junit.runner.JUnitCore”

classpath = configurations.cucumberRuntime + sourceSets.main.output + sourceSets.test.output

args = [‘com.erecyclingcorps.test.’ + ([“”].tokenize("_")[0]).toUpperCase() + ‘Test’]



} }

task testReport(type: TestReport) {

destinationDir = file("$buildDir/reports/allTests")

// Include the results from the ‘test’ task in all subprojects

reportOn test }

dependencies {

compile ‘org.seleniumhq.selenium:selenium-java:2.32.+’

compile ‘org.apache.commons:commons-lang3:3.1’

compile ‘org.springframework:spring-context:3.2.3.RELEASE’

testCompile ‘info.cukes:cucumber-java:1.1.3’

testCompile ‘info.cukes:cucumber-junit:1.1.3’

testCompile ‘info.cukes:cucumber-spring:1.1.3’

testCompile ‘junit:junit:4.10’

testCompile ‘org.easytesting:fest-assert-core:2.0+’


Junit version is 4.10.

actually real thing was that i need to generate report for test executed. but for that i have been told that tests should run fine through Gradle first.

Please let me know if you want some more details.

Hard to say. Maybe you have code under ‘src/main/java’ that tries to use JUnit.

PS: The ‘TestReport’ task only works with ‘Test’ tasks (but you overwrite the latter).

yes i have code under stepDefs using junit. like iam using Assert method there and also imported org.Junit.Assert in the code.