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

Search Java Interview Questions


 2098 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Assert' - 6 question(s) found - Order By Newest

 Q1. What is assert keyword used for ?
Anonymous
Ans. The assert keyword is used to make an assertion—a statement which the programmer believes is always true at that point in the program. This keyword is intended to aid in testing and debugging.

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

   Like      Discuss      Correct / Improve     java   junit.assert   testing   white box testing


 Q2. Difference between Assert and Verify ?
admin
info@buggybread.com
Ans. Assert works only if assertions ( -ea ) are enabled which is not required for Verify.

Assert throws an exception and hence doesn't continue with the test if assert evaluates to false whereas it's not so with Verify.

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

   Like      Discuss      Correct / Improve     assert   junit   mockito   verify   testing   unit testing   barclays


 Q3. Tell me something about AssertionError ?Core Java
Admin
info@buggybread.com
Ans. AssertionError is actually a fatal fault or a bug in the program. We may not like to continue program , request or thread execution if this error occurs as this condition is the assumption to continue further execution.

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

   Like      Discuss      Correct / Improve     java   error   exceptions   exception handling   assertion error   assertionerror


 Q4. Does a Junit without any assertions makes any sense ?Junit2017-05-09 13:34:52

Ans. Yes, If we are testing a code segment to check if throws / doesn't throw an exception. Moreover while testing void methods, we may just verify and not use assert.

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

   Like      Discuss      Correct / Improve     junit  assert


 Q5. What are the benefits of assertThat over assert in Junits ?Junit2017-05-17 16:50:18

Ans. assertThat is introduced with Junit4 and offers many advatanges over assert. Messages are more explanatory, offer better type safety and are more readable. Moreover hamcrest library is portable as it can used both with junit and TestNG.Moreover assertThat provides flexibility as the same method can be used for assert , assertEquals,assertTrue etc through the use of matcher methods.

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

   Like      Discuss      Correct / Improve     assertThat  assert  assert vs assertThat


 Q6. Can you name few matchers that can be used with hamcrest assertThat method ?Junit2017-05-17 16:52:13

Ans. is
not
equals
anyOf
hasSize

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

   Like      Discuss      Correct / Improve     assertThat.hamcrest




Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner



comments powered by Disqus
 

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:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: