Sunday, October 8, 2017

Junit interview questions and answers

1. What is Junit.

    Junit is a open source unit testing framework in Java languages. Developers are using this for unit testing for his code. It provides different annotations which are help in unit testing. It also provides the test runner to run the test.


2. What is test runner ?

    Test runner is used to execute the junit testcases.

3. What is @Ignore annotation in Junit ?

    By using this annotation we can ignore testcase in Junit framework.

4. List some Junit extensions ?

    JWebUnit
    XMLUnit
    MockObject
    Cactus

5.What is difference between @Before and @BeforeClass ?

@Before :- This annotation will always execute before each test.

@BeforeClass :- This annotation will execute before all the tests. It will execute only once.


6. How to write first testcase using Junit ?

   import org.junit.*;

   public void printHello(){
 
   String s="Hello";
   Assert.assertEquals(s, "Hello World !")

}





No comments:

Post a Comment