/** * Execute the {@link Runnable#run()} method, record the SQL queries * and return the {@link Spy} object with stats * @param runnable code to test * @return statistics on executed queries * @since 3.1 */ public static Spy run(Runnable runnable) { return spy().run(runnable); }
/** * Execute the {@link Runnable#run()} method, record the SQL queries * and return the {@link Spy} object with stats * @param runnable code to test * @return statistics on executed queries * @since 3.1 */ public static Spy run(Runnable runnable) { return spy().run(runnable); }
@Test public void testRunThrowsException() throws Exception { try { Sniffer.expect(1).run(() -> { throw new RuntimeException(); }); } catch (RuntimeException e) { assertNotNull(e); assertNull(e.getCause()); assertEquals(1, e.getSuppressed().length); assertTrue(WrongNumberOfQueriesError.class.isAssignableFrom(e.getSuppressed()[0].getClass())); } }