@Test public void should_fetch_all_scripts_defined_for_test_class() throws Exception { // given TestEvent testEvent = createTestEvent("shouldPassWithDataButWithoutFormatDefinedOnMethodLevel"); SqlScriptProvider<ApplyScriptBefore> scriptsProvider = createSqlScriptProviderFor(testEvent); // when Collection<SqlScriptResourceDescriptor> scriptDescriptors = scriptsProvider.getDescriptors(testEvent.getTestClass()); // then SqlScriptDescriptorAssert.assertThat(scriptDescriptors) .containsOnlyFollowingFiles( SQL_DATA_SET_ON_CLASS_LEVEL, SQL_DATA_SET_ON_METHOD_LEVEL, DEFAULT_FILENAME_FOR_TEST_METHOD, "one.sql", "two.sql", "three.sql"); }
private void doProcess(TestEvent event) { Object testCase = event.getTestInstance(); TestClass testClass = event.getTestClass(); String testMethodName = event.getTestMethod().getName(); for (Method m : filterAndOrderMethods(testMethodName, testClass.getMethods(annotationClass))) { try { m.invoke(testCase, (Object[]) null); } catch (Exception e) { throw new IllegalStateException( "Failed to execute @" + annotationClass.getSimpleName() + " method [" + m + "] - cause: " + e, e); } } }
private SqlScriptProvider<ApplyScriptBefore> createSqlScriptProviderFor(TestEvent testEvent) { return SqlScriptProvider.createProviderForScriptsToBeAppliedBeforeTest( testEvent.getTestClass(), defaultConfiguration); }