Thursday, July 12, 2018

JUnit

JUnit  Software Installation




1)  It is  an Opensource software
2)  It is in the form of .jar file.
3)  Download junit.jar  freely from  https://github.com/junit-team/junit4/wiki/Download-and-Install
4)  Latest  version  --   5.x ,   popular is 4.12 ( as on June 2018)
5)   How to enabled Junit  Jar ?

            a)  without Maven

                         Need to set  junit jar into  classpath.  With this  we can access all the classes from
                        junit jar.

            b) with Maven

                         Add junit  dependency  in pom.xml, so that  junit,jar  will be set  into  classpath

                                 <dependency>
                    <groupId>junit</groupId>
                   <artifactId>junit</artifactId>
                    <version>4.12</version>
                  <scope>test</scope>
                      </dependency>
   
JUnit  Annotations  (   all below are available  from package org.junit.* )

1.  @BeforeClass   -    It will execute only once for all the test cases.
2.  @Before            -   It will execute only once for before every test cases.
3.  @Test                -   Junit test case
4.  @Ignore
5.  @Runwith
6.  @After             -   It will execute only once for after  every test cases
7.  @AfterClass     -  It will execute only once for before every test cases.

Methods  ( All are available from  junit.Assert.*)

assertTrue()
assertFalse()
assertNotNull()
assertEquals()
  :
   assertxxx()





No comments:

Post a Comment

Hyderabad Trip - Best Places to visit

 Best Places to Visit  in Hyderabad 1.        1. Golconda Fort Maps Link :   https://www.google.com/maps/dir/Aparna+Serene+Park,+Masj...