JUnit 4.x – Testing Framework : JUnit Setup
After download, you will get junit-4.12.jar.
if extract this file you will get junit-4.12.jar file that you need to place as library in your project.
|JUnit as Eclipse Plugin|
Create Java Project as below and ADD junit-4.12.jar file by using configure build path as below
Note: You can take java sample code that is available on previous chapter.
If you have downloaded above zip file and configured with eclipse then you are ready to move with JUnit Testing Framework.
Run the TestFile which is mentioned as below
And you will find that 1 test out of 4 test got failed. since “Hello world” message is not same.
Change “Hello World” message where ‘w’ is capital. and then run the test again where you will find that all test got success.
With Maven Tool
Add a dependency to junit:junit in test scope. (Note: 4.12 is the latest stable version as of the latest edit on this page.)
<dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency>