| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
Can you add the DCO? |
Sorry, something went wrong.
Signed-off-by: Elvys Soares <eas5@cin.ufpe.br>
|
Thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is a test refactoring.
Problem:
The Exception Handling test smell occurs when explicitly a passing or failing of a test method is dependent on the production method throwing an exception.
Solution:
The use of JUnit's exception handling to automatically pass/fail the test instead of writing custom exception handling code or throwing an exception is encouraged.
Result:
Before:
@Test public void testUnbound() throws IOException { CollectorRegistry registry = new CollectorRegistry(); try { HTTPServer s = new HTTPServer(HttpServer.create(), registry, true); s.stop(); fail("Should refuse to use an unbound HttpServer"); } catch (IllegalArgumentException expected) { } }After:
@Test(expected = IllegalArgumentException.class) public void testRefuseUsingUnbound() throws IOException { CollectorRegistry registry = new CollectorRegistry(); HTTPServer s = new HTTPServer(HttpServer.create(), registry, true); s.stop(); }