java - Testing for optional exception in parameterized JUnit 4+ test -
I am trying to write a unit test for a method that takes a string as a parameter and a Exceptions are distorted (and if it's okay then none). I want to write a parametred test that feeds in many strings and expected exceptions (in which none is thrown when input string is created well!). If @Test (expect = SomeException.class) is trying to use annotations, then I have two problems: Expected = Null is not allowed, so I How can I test for the expected outcome of an exception (for well-formed input wires)? Expected = Not possible? I have not tried this yet, but I have a strong doubt that this is the case after reading (Can you please tell that this is true?): This is the best solution I have found so far. What do you think about it, especially than that: Thanks for any help, I look forward to discussion :) ValidStringsTest InvalidStringsTest / Li> Remember: Readability of your tests is even more important: Note: Already examines all valid assumptions (n...