JUnit exception testing

Now a days while I discover TDD and testing in software development, I’ve come to realize that it is also possible to test exceptions in Junit as well. I’ve noticed this while I was checking a code snippet of a software online and right after that I’ve tested the same thing to see the outcome.

How do I test File api in Junit

I was looking for a way to test Java file apis, especially I’ve such methods which return Java File. I somehow felt that those methods also have to be tested at least a small test case could be conducted. I did check what File api returns at Oracle Api Docs. The Method you’ll observe below