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.
Ans. Yes, We can pass the test even if the tested method throws an exception.
One way is know as exception testing in which the tested method is expected to throw exception and hence the expectation is set accordingly.
@Test(expected = IndexOutOfBoundsException.class)
public void test(){}
Other way is to just ignore if the tested code throws an exception. In that case , we can enclose the tested method call in the try block and within exception block, we just return gracefully.
Exception testing is perfectly ok to be done as we would like test code in case an exception occurs and if the code is handling the exception properly. Ignoring the exception by putting the tested method call within try block isn't something normal and should be avoided.
Help us improve. Please let us know the company, where you were asked this question :
Ans. A try block can be followed by one or more catch blocks. Each catch block must contain a different exception handler. So, if you have to perform different tasks at the occurrence of different exceptions, use java multi-catch block.
Help us improve. Please let us know the company, where you were asked this question :
Ans. When we Mock an object and then make a reference to any method using mocked object reference , java never makes a call to that method and looks for mocked value to be returned or null if none specified. But If we want that to be overridden and want java to make actual method call upon using mocked object reference, this method can be used.
Help us improve. Please let us know the company, where you were asked this question :
Ans. Unit Testing ( Junits )
Integration Testing ( Testing overall flow by calling the entry method or by calling the service end point )
Manual Testing ( End to End Manual User Testing, they way eventually it will be used by end users )
Automation Testing ( Machine replication of end to end testing )
Help us improve. Please let us know the company, where you were asked this question :
Ans. Selenium WebDriver is a tool for automating web application testing.It helps in replicating the manual tester behavior like keyboard entry, mouse events etc and then matching the output against the expected.
Help us improve. Please let us know the company, where you were asked this question :
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 :