-
Notifications
You must be signed in to change notification settings - Fork 28
Getting Started
Jinho D. Choi edited this page Aug 28, 2017
·
27 revisions
- Download JDK 8 and install.
- Download the latest version of IntelliJ, install, and launch the program.
- Create a new project called
CS323
:- Choose "Java" on the left pane.
- Make sure the project SDK indicates a java version "1.8.x".
- Right click on the
src
directory and create a package calledutils
. - Right click on the
utils
package and create a class calledUtils
. - Add the following methods to the
Utils
class:static public int getMiddleIndex(int beginIndex, int endIndex) { return beginIndex + (endIndex - beginIndex) / 2; } static public void main(String[] args) { System.out.println(getMiddleIndex(0, 10)); }
- Run the program by choosing
[Run -> Run]
. - If you see
5
on the console, your program is successfully run.
- Right click on the
utils
package and create a class calledUtilsTest
. - Add the following method to the
UtilsTest
class:@Test void getMiddleIndexTest() { assertEquals(Utils.getMiddleIndex(0, 10), 5); }
- Make sure to include the
@Test
annotation. You must see@Test
in red. Hover over and addJUnit 5
. - Import the followings:
import static org.junit.jupiter.api.Assertions.assertEquals; import org.junit.jupiter.api.Test;
- Make sure to include the
- Run the test by choosing
[Run -> Run]
. - If you see a green bar with the message "1 test passed", your program passed the unit test.
- Choose [File -> Project Structure].
- Choose the java version you want for the project SDK. If the java version is not shown, click the
New
button and add. - Choose the project language level to the same java version.
- Submit
Utils.java
andUtilsTest.java
: https://canvas.emory.edu/courses/32845/assignments/69821
Copyright © 2014-2017 Emory University - All Rights Reserved.