- Interview Questions and Answers for 'Junit annotations' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



- Interview Questions and Answers for 'Junit annotations' - 2 question(s) found - Order By Newest

 Q1. How to create a Junit to make sure that the tested method throws an exception ?
admin
info@buggybread.com
Ans. Using annotation Test with the argument as expected exception.

@Test (expected = Exception.class)

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     junit   junit annotations


Related Questions

  How should we ignore or avoid executing set of tests ?
  How can we test methods individually which are not visible or declared private ?
  What are the steps to be performed while coding Junit with Mocking framework ?
  What is assert keyword used for ?
  Difference between Assert and Verify ?
  What are the annotations used in Junit with Junit4 ?
  What should I do if I want to make sure that a particular method of a class is getting called ?
  What is the use of Mockito.any ?
  Name few Java Mocking frameworks ?


 Q2. What are the annotations used in Junit with Junit4 ?
Admin
info@buggybread.com
Ans. @Test

The Test annotation indicates that the public void method to which it is attached can be run as a test case.

@Before

The Before annotation indicates that this method must be executed before each test in the class, so as to execute some preconditions necessary for the test.

@BeforeClass

The BeforeClass annotation indicates that the static method to which is attached must be executed once and before all tests in the class.

@After

The After annotation indicates that this method gets executed after execution of each test.

@AfterClass

The AfterClass annotation can be used when a method needs to be executed after executing all the tests in a JUnit Test Case class so as to clean-up the set-up.

@Ignores

The Ignore annotation can be used when you want temporarily disable the execution of a specific test.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   junit   jnuit4   junit annotations


Related Questions



 Q3. Which of following annotation is used to initialize objects before executing set of tests ?Junit
a. @Test
b. @Ignore
c. @After
d. @Before

Ans.d. @Before


Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: