# Hello world JUnit

**URL:** https://discuss.gradle.org/t/hello-world-junit/14090
**Category:** Help/Discuss
**Created:** [February 2, 2016, 10:45am UTC](https://discuss.gradle.org/t/hello-world-junit/14090 "2016-02-02T10:45:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![THUFIR](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@THUFIR](https://discuss.gradle.org/u/THUFIR)
#### Post date: [February 2, 2016, 10:45am UTC](https://discuss.gradle.org/t/hello-world-junit/14090/1 "2016-02-02T10:45:21Z")

</div>

what is wrong with the build file that the compile fails with

`  
thufir@mordor:~/java/hello\_gradle$  
thufir@mordor:~/java/hello\_gradle$ gradle clean;gradle build  
:clean UP-TO-DATE

BUILD SUCCESSFUL

Total time: 4.253 secs  
:compileJava  
/home/thufir/java/hello\_gradle/src/main/java/net/bounceme/mordor/hello/TestJunit.java:3: error: package org.junit does not exist  
import org.junit.Test;  
^  
/home/thufir/java/hello\_gradle/src/main/java/net/bounceme/mordor/hello/TestJunit.java:4: error: package org.junit does not exist  
import static org.junit.Assert.assertEquals;  
^  
/home/thufir/java/hello\_gradle/src/main/java/net/bounceme/mordor/hello/TestJunit.java:4: error: static import only from classes and interfaces  
import static org.junit.Assert.assertEquals;  
^  
/home/thufir/java/hello\_gradle/src/main/java/net/bounceme/mordor/hello/TestJunit.java:11: error: cannot find symbol  
@Test  
^  
symbol: class Test  
location: class TestJunit  
/home/thufir/java/hello\_gradle/src/main/java/net/bounceme/mordor/hello/TestJunit.java:13: error: cannot find symbol  
assertEquals(message,messageUtil.printMessage());  
^  
symbol: method assertEquals(String,String)  
location: class TestJunit  
5 errors  
:compileJava FAILED

FAILURE: Build failed with an exception.

- What went wrong:  
Execution failed for task ‘:compileJava’.

> Compilation failed; see the compiler error output for details.

- Try:  
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 5.148 secs  
thufir@mordor:~/java/hello\_gradle$  
thufir@mordor:~/java/hello\_gradle$ cat build.gradle  
apply plugin: ‘java’

```
version = "0.5"

repositories {
mavenCentral()

```

}

dependencies {  
testCompile ‘junit:junit:4.8.2’  
}

jar {  
manifest {  
attributes ‘Main-Class’: ‘hello.HelloWorld’  
}  
}

task hello \<\< {  
println ‘hello, world’  
}

thufir@mordor:~/java/hello\_gradle$

`

The full code is at:

> **[GitHub - THUFIR/hello\_gradle](https://github.com/THUFIR/hello_gradle)**
>
> Contribute to THUFIR/hello\_gradle development by creating an account on GitHub.

but I’m also looking at:

> **[GitHub - THUFIR/java-maven-junit-helloworld: A „Hello World!” sample written...](https://github.com/THUFIR/java-maven-junit-helloworld)**
>
> A „Hello World!” sample written in Java that showcases very simple unit and integration tests. - GitHub - THUFIR/java-maven-junit-helloworld: A „Hello World!” sample written in Java that showcases ...

which works fine with maven.

---

<div class="post-metadata">

### Author: ![THUFIR](https://avatars.discourse-cdn.com/v4/letter/t/ee7513/32.png) [@THUFIR](https://discuss.gradle.org/u/THUFIR)
#### Post date: [February 2, 2016, 11:07am UTC](https://discuss.gradle.org/t/hello-world-junit/14090/2 "2016-02-02T11:07:30Z")

</div>

I wasn’t using the main and test directories correctly. The build works, learning how to run tests now. Code is updated.
