Hi,
I'm trying to build some jUnit tests for a plugin.
In this plugin there is a method called readExcelFile() that throws FileNotFoundException and IOException.
Any idea how the test should look like to test it for the FileNotFoundException is thrown?
My code:
@Test(expected = FileNotFoundException.class) public void testParsedFile(){ MyPluginComponent component = new MyPluginComponentImpl(null); component.readExcelFile("C:/Users/abc/Desktop/ClarityExportSample.xlsx"); }
Line 4 gives me an error that I have to catch the IOException. But I actually want to test if the FileNotFoundException is thrown here.
Community moderators have prevented the ability to post new answers.
Well, FileNotFound exception is a sub of IOException. Your component.readExcelFile should throw the right exception.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.