Skip to content

Instantly share code, notes, and snippets.

@eleco
Last active December 26, 2015 04:08
Show Gist options
  • Save eleco/7090459 to your computer and use it in GitHub Desktop.
Save eleco/7090459 to your computer and use it in GitHub Desktop.
log exception
package com.company;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Item {
Logger log = Logger.getLogger("ItemLogger");
public boolean function(String param) {
if (param==null) {
log.log(Level.SEVERE,"error", new IllegalArgumentException("boom"));
return false;
}
return true;
}
}
package com.company;
import org.junit.Test;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class ItemTest {
@Test
public void testFunction() {
assertThat(new Item().function(null),is(false));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment