This section includes 7 InterviewSolutions, each offering curated multiple-choice questions to sharpen your Current Affairs knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How Can We Test Methods Individually Which Are Not Visible Or Declared Private? |
|
Answer» We can EITHER increase their visibility and MARK them with annotation @VisibleForTesting or can use REFLECTION to individually TEST those METHODS. We can either increase their visibility and mark them with annotation @VisibleForTesting or can use reflection to individually test those methods. |
|
| 2. |
How Should We Ignore Or Avoid Executing Set Of Tests? |
|
Answer» We can remove @Test from the respective test so as to avoid its EXECUTION. Alternatively we can put @Ignore annotation on the Junit FILE if we want to ignore all tests in a PARTICULAR file. We can remove @Test from the respective test so as to avoid its execution. Alternatively we can put @Ignore annotation on the Junit file if we want to ignore all tests in a particular file. |
|
| 3. |
What Is The Use Of Mockito.any? |
|
Answer» In case we need to VERIFY that a METHOD is being called with any ARGUMENT and not a specific argument we can use Mockito.any(Class), Mockito.anyString, Mockito.anyLong etc. In case we need to verify that a method is being called with any argument and not a specific argument we can use Mockito.any(Class), Mockito.anyString, Mockito.anyLong etc. |
|
| 4. |
Name Few Java Mocking Frameworks? |
|
Answer» MOCKITO, POWERMOCK, EASYMOCK, JMOCK, JMockit. Mockito, PowerMock, EasyMock, JMock, JMockit. |
|
| 5. |
What Should I Do If I Want To Make Sure That A Particular Method Of A Class Is Getting Called ? |
|
Answer» If its a STATIC method of the class , we can use VERIFY to make sure it's getting CALLED. If its a static method of the class , we can use verify to make sure it's getting called. |
|
| 6. |
How To Create A Junit To Make Sure That The Tested Method Throws An Exception ? |
|
Answer» USING ANNOTATION TEST with the ARGUMENT as expected exception. Using annotation Test with the argument as expected exception. |
|
| 8. |
Which Package Assert Belong To? |
|
Answer» java.unit java.unit |
|
| 9. |
How To Test Whether The Returns Value Of The Method Is Expected ? |
|
Answer» Using Assert. |
|
| 10. |
Are Junits Tested Manually? |
|
Answer» No , they are EXECUTED AUTOMATICALLY. No , they are executed automatically. |
|
| 11. |
What Are Junits ? |
|
Answer» JUNT is the UNIT TESTING FRAMEWORK for JAVA. Junt is the unit testing framework for Java. |
|