Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Install and Setup JavaSDK and Cucumber (MacOS): Difference between revisions

From KKM-STUDIO-WIKI
Line 18: Line 18:
[[image:mac03.png|500x300px|center|thumb|Install and Verify JavaSDK]]
[[image:mac03.png|500x300px|center|thumb|Install and Verify JavaSDK]]


If this is not the case, you also need to create a symlink for the system Java wrappers to find this JDK: <code class="mwt-code">sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \ /Library/Java/JavaVirtualMachines/openjdk.jdk</code>. After that, try to verify the JavaSDK again on your terminal.&nbsp;
If this is not the case, you also need to create a symlink for the system Java wrappers to find this JDK: <code class="mwt-code">sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \ /Library/Java/JavaVirtualMachines/openjdk.jdk</code>. After that, try to verify the Java SDK again in your terminal.


= Download and Install IDE (Eclipse or IntelliJ) =
= Download and Install IDE (Eclipse or IntelliJ) =

Revision as of 17:40, 5 January 2024

READ ME FIRST

  • This tutorial applies to the MAC operating system, you can also check WINDOWS tutorial.
  • This tutorial is based on this file (Programming Exercises Course 02161 Week 1 written by Hubert Baumeister in January 2022) to make additions and changes.
  • Contact Shuokai Ma (s214919@student.dtu.dk) if you find a problem or have suggestions for this Wiki.

Install Homebrew

Go to the Homebrew Installation Page. Copy the following code to your terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

The terminal will ask you to provide your password. Enter your password and then press the RETURN/ENTER to continue.

Homebrew Installation

Once the installation is done, you can check if you have installed the Homebrew successfully by writing brew --versionin the terminal. It should show the following message:

Verify Homebrew

Install and Verify JavaSDK

Open your terminal and write the following code: brew install java. The Homebrew should then do all things for you.  

Then check your installation by running java -version

Install and Verify JavaSDK

If this is not the case, you also need to create a symlink for the system Java wrappers to find this JDK: sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \ /Library/Java/JavaVirtualMachines/openjdk.jdk. After that, try to verify the Java SDK again in your terminal.

Download and Install IDE (Eclipse or IntelliJ)

The course will use Eclipse in its teaching material but all the things we do in the course can be done in IntelliJ too. You can download the latest version of Eclipse and IntelliJ (Community Edition) here. After that, you can follow the instructions of the installation wizard to install the IDE.

Download and Install the Cucumber plugin

Eclipse

From the Eclipse marketplace (from inside the Help menu of Eclipse), download the "Cucumber" plugin.

Install Cucumber (Eclipse)

IntelliJ

IntelliJ already comes with a Cucumber plugin. But I recommend you also download a plugin called Cucumber for Java since it can add support for Cucumber testing tools with step definitions written. You can download that from IntelliJ IDEA -> Settings -> plugins

Install Cucumber (IntelliJ)

Restart your IDE

After you install the Cucumber plugin, you need to restart your IDE (Your IDE will also notify you to do that).

Download and Import the project "libaray01" to your IDE

You can download the zip file library01.zip here. And then you should unpack the zip file first.

Eclipse

You can now import the project into Eclipse by clicking File -> Import -> General -> Projects from Folder or Archive. And then you click the Directory and choose the file you unpacked from the zip file. Then you mark that project library01 and click Finish.

Import project (Eclipse)

IntelliJ

You can now import the project into IntelliJ by clicking Open and Choosing the file pom.xml you unpacked from the zip file. Then click OK and Open as Project.

Import project (IntelliJ)

Run the project in your IDE

Eclipse

Find the file AcceptanceTest.java under the src/test/java/dtu.library.acceptance_tests and then right-click -> Run as -> JUnit Test. You will see the following content:

Run the project in Eclipse

Although the program fails the test (as it should), it proves that you can already run the cucumber plugin. You can now begin to implement the production code such that the scenarios "Admin login", "Admin logout", "Add book", and "Search book" pass. After implementing the first scenario on "Admin login", you should see the following:

Successfully passed the first scenario test in Eclipse

IntelliJ

Find the file AcceptanceTest.java under the src/test/java/dtu.library/acceptance_tests and then right-click -> Run 'AcceptanceTest'. You will see the following content:

Run the project in IntelliJ

Although IntelliJ shows "build failed" at first, you can assume that you can already run the cucumber plugin. You can now begin to implement the production code such that the scenarios "Admin login", "Admin logout", "Add book", and "Search book" pass. After implementing the first scenario on "Admin login", you should see the following:

Successfully passed the first scenario test in IntelliJ