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