@Test public void should_fetch_data_file_name_from_test_level_annotation() throws Exception { // given String expectedDataFile = SQL_DATA_SET_ON_METHOD_LEVEL; TestEvent testEvent = createTestEvent("shouldPassWithDataButWithoutFormatDefinedOnMethodLevel"); SqlScriptProvider<ApplyScriptBefore> scriptsProvider = createSqlScriptProviderFor(testEvent); // when List<String> dataFiles = new ArrayList<String>(scriptsProvider.getResourceFileNames(testEvent.getTestMethod())); // then assertThat(dataFiles).containsOnly(expectedDataFile); }
@Test public void should_provide_default_file_name_when_not_specified_in_annotation() throws Exception { // given String expectedFileName = DEFAULT_FILENAME_FOR_TEST_METHOD; TestEvent testEvent = createTestEvent("shouldPassWithDataFileNotSpecified"); SqlScriptProvider<ApplyScriptBefore> scriptsProvider = createSqlScriptProviderFor(testEvent); // when List<String> files = new ArrayList<String>(scriptsProvider.getResourceFileNames(testEvent.getTestMethod())); // then assertThat(files).containsOnly(expectedFileName); }
@Test public void should_provide_default_file_name_when_not_specified_in_annotation_on_class_level() throws Exception { // given String expectedFileName = "before-" + ApplyScriptBeforeAnnotatedOnClassLevelOnly.class.getName() + ".sql"; TestEvent testEvent = new TestEvent( new ApplyScriptBeforeAnnotatedOnClassLevelOnly(), ApplyScriptBeforeAnnotatedOnClassLevelOnly.class.getMethod("shouldPass")); SqlScriptProvider<ApplyScriptBefore> scriptsProvider = createSqlScriptProviderFor(testEvent); // when List<String> files = new ArrayList<String>(scriptsProvider.getResourceFileNames(testEvent.getTestMethod())); // then assertThat(files).containsOnly(expectedFileName); }