Hi Nuwan, Sorry for barging in like this. I agree with your statement, but what if we want to pass a test cases only if a specific exception is thrown. TestNG allows the "expectedExceptions" annotation to help this out. See [1]. Else we would have to use a try/catch to catch the specific exception and then pass or fail the test case using Assert.fail() method depending on the implementation.
[1] - http://www.tutorialspoint.com/testng/testng_exception_test.htm Regards, Hemika Hemika Kodikara Software Engineer WSO2 Inc. lean . enterprise . middleware http://wso2.com Mobile : +94777688882 On Thu, Jul 2, 2015 at 6:16 PM, Nuwan Wimalasekara <[email protected]> wrote: > Hi > > It is always better to throw the Exception(super class) as a best practice > when we define a test method rather than throwing the list of particular > exceptions since no one will catch those exception and handle explicitly. > Then it will ensure that the test method will not break once the methods > used within the test method changed and in the test reports It shows the > actual Exception class. So It will ease the test classes maintainability. > > @Test() > public void testMethod() throws *Exception* { > > ............ > } > > Thanks, > Nuwanw > > -- > Nuwan Wimalasekara > Senior Software Engineer - Test Automation > WSO2, Inc.: http://wso2.com > lean. enterprise. middleware > > phone: +94 71 668 4620 > > > > > _______________________________________________ > Dev mailing list > [email protected] > http://wso2.org/cgi-bin/mailman/listinfo/dev > >
_______________________________________________ Dev mailing list [email protected] http://wso2.org/cgi-bin/mailman/listinfo/dev
