# **JUnit Example**
## This example can be completed using either Method 1 (Terminal) or Method 2 (VSCode Extension)
## Method 1 (Terminal) [Works with any IDE]
Open this [github link](https://github.com/Darleenie/junitDemo) and download the repository (Click the green button labeled "code" then click "Download ZIP"). **Note**: The .jar files located in the "lib" folder are important for running JUnit tests.
1. Open your terminal/command prompt and change the directory to the repository you just downloaded (i.e., week1Discussion-main)
2. Run these commands:
Mac Users:
Compile:
`javac -cp libs/junit-4.12.jar:libs/hamcrest-core-1.3.jar:. DemoArrayImplTester.java`
Execute:
```java -cp libs/junit-4.12.jar:libs/hamcrest-core-1.3.jar:. org.junit.runner.JUnitCore DemoArrayImplTester```
Window Users:
Compile:
`javac -cp ".;libs\junit-4.12.jar;libs\hamcrest-core-1.3.jar" DemoArrayImplTester.java`
Execute:
`java -cp ".;libs\junit-4.12.jar;libs\hamcrest-core-1.3.jar" org.junit.runner.JUnitCore DemoArrayImplTester`
Command explanation:
**javac:** compilation.
**libs/junit-4.12.jar:libs/hamcrest-core-1.3.jar:.** dependencies needed to compile JUnit tests.
**DemoArrayImplTester.java:** The java file containing the JUnit tests.
**Please complete the TODOs! (No need to turn anything in)**
## Method 2 (VScode extension)
Download the github repo as explained above. Then, open the folder in VSCode (File > Open Folder > Click on the repository)
---
Once the files are added, you might notice that there are some red errors.

1. On the left side of VSCode, there are ICONS, please click on the icon that looks like a beaker. If there is no beaker, please click on the extensions icon (square blocks) and download "Extension Pack for Java".
**Note:** The beaker icon will only show up if you have the tester file "DemoArrayImplTester.java" open.

2. Please Enable Java Test and select **JUnit** not **JUnit Jupiter**


3. Then you will see the unit Tests if they pass or fail. All of them will pass but this image below is an idea of what should look like.

They will look like they are passed because there is nothing in the TODO Test
**Also** complete TODOs!