- The added line is THIS COLOR.
- The deleted line is THIS COLOR.
#contents
*Prerequisite [#o693f181]
(Mandatory)
-Java SDK installation
(Optional)
The explanation in this page assumes the following.
-Eclipse installation (You can refer [[Overall/Eclipse]])
-Maven installation (You can refer [[Overall/Maven]])
-Cygwin instattion (You can refer [[Overall/Cygwin]])
*Install&Setup [#dd76bdf3]
:Step.1|
xxx
(We can use maven)
*HowToUse [#v42b8a3e]
**Create project. [#vf5660d2]
:Step.1|
Launch Cygwin.
:Step.2|
Create the most simple maven project.
$ mvn archetype:create \
-DgroupId=org.test \
-DartifactId=project
#ref(CreateMavenProject_fig1.png)
#ref(CreateMavenProject_fig1.png,,500x275,)
:Step.3|
Sample production code App.java and AppTest.java will be created.
You can execute testing by the following command.
$ mvn test
#ref(CreateMavenProject_fig2.png)
#ref(CreateMavenProject_fig2.png,,500x275,)
**Import mvn project to eclipse [#q7164746]
:Step.1|
Luanch eclipse.
:Step.2|
Select File -> Import.
#ref(ImportMavenProject_fig1.png)
#ref(ImportMavenProject_fig1.png,,500x620,)
:Step.3|
Select "Existing Maven Projects" and click "next" button.
#ref(ImportMavenProject_fig2.png)
#ref(ImportMavenProject_fig2.png,,500x285,)
:Step.4|
Click "Browse" button and select created maven project folder.
#ref(ImportMavenProject_fig3.png,,500x349,)
#ref(ImportMavenProject_fig4.png,,500x349,)
:Step.5|
Click "Finish" button. And you have imported eclipse project.
#ref(ImportMavenProject_fig5.png,,500x266,)
**Prepare source code. [#z664953c]
:Step.1|
Create production code.
Create sample production code, "Calc" as follows.
[[sample code - Calc:https://github.com/osssv/osssv-helloworld/blob/master/junit/4.8/project/src/main/java/org/test/Calc.java]]
https://github.com/osssv/osssv-helloworld/blob/master/junit/4.8/project/src/main/java/org/test/Calc.java
#ref(CreateCode_fig1.png)
#ref(CreateCode_fig1.png,,500x361,)
:Step.2|
Select "File"->"New"->"JUnit Test Case" (lower one).
#ref(CreateCode_fig2.png)
#ref(CreateCode_fig2.png,,500x364,)
:Step.3|
Select "New JUnit 4 test" and click "Finish" button.
#ref(CreateCode_fig3.png)
#ref(CreateCode_fig3.png,,500x364,)
:Step.4|
When the JUnit 4 is not on the build path, eclipse ask if we setup it or not.
Here, we choose "Not now" and click "OK" button.
#ref(CreateCode_fig4.png)
Here, we choose "Not now" and click "OK" button. We will use maven later for this.
#ref(CreateCode_fig4.png,,500x166,)
:Step.5|
Open POM.xml and edit it as following.
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
[[sample code - POM.xml:https://github.com/osssv/osssv-helloworld/blob/master/junit/4.8/project/pom.xml]]
:Step.6|
Execute the following command. Maven download JUnit4 and setup it to the build-path based on the description in POM.xml.
$ cd <Maven project directory>
$ mvn test
#ref(CreateCode_fig7.png,,500x275,)
:Step.5|
Create test code.
Now we have JUnit in project, too.
#ref(CreateCode_fig6.png,,500x266,)
:Step.6|
Execute test.
*Author [#e6401f0e]
S.Yatsuzuka