Can't suppress DriverManager's static initializer block
I have a unit test that attempts to create a SQLException to simulate a database error. In SQLException 's constructor, there is a call to DriverManager , which has a static initialization block. I figured that I could suppress the static block with this type of setup: @RunWith(PowerMockRunner.class) @SuppressStaticInitializationFor({"java.sql.DriverManager"}) public class StaticTest { @Test public void testStaticSuppress() throws Exception { SQLException ex = new SQLException(); expect(...).andThrow(ex); } } When I run the test, the static block in DriverManager is still called. What am I