- Where Developers Learn, Share, & Build Careers
I'm having difficulty using the required annotation of June 4 to see exceptions. I can not compile the code because it has an unrestricted exception
This is a simple example that creates a situation:
import static org.junit.Assert. *; Import java.io.UnsupportedEncodingException; Import org.junit.Test; Public class simple {@ test (expected = unsupported encoding exception. Clash) Public Zero Simple () {string A = ""; A.getBytes ("UTF-123"); }} I get a compilation error called "compiled exception type unsupported encoding exception"
It makes sense, and I can make it clear that Simplified unsupported encoding throws an exception, we have seen many examples online where people do not do it (which would be good when writing a lot of test cases).
Is there a way to configure the test case, which clearly tell me what exceptions will be thrown?
As far as I know, unsupported encoding exceptions are a check exception, therefore the compiler expects That throws the section for a checked exception. I think your code will work, if you say that you have tried an arbitrary exception such as arithmetic exception.
Comments
Post a Comment