/** * Constructs an iteration of test case definitions from various test data sources, obtained from * the mvn command line option. See README.md for more details. * * @return an iteration of object arrays that defines the set of tests to be executed. * @throws Exception */ public static List<DrillTestCase> getDrillTestCases() throws IOException { String[] testDefSources = null; try { testDefSources = TestDriver.OPTIONS.sources.split(","); } catch (Exception e) { testDefSources = new String[] {""}; // Look at the default location for test definition files } String[] testGroups = null; try { testGroups = TestDriver.OPTIONS.groups.split(","); } catch (Exception e) { LOG.info("Test groups not specified. Will run all collected tests."); } List<DrillTestCase> drillTestCases = new ArrayList<>(); for (String testDefSource : testDefSources) { testDefSource = Utils.getAbsolutePath(testDefSource, "DRILL_TEST_DATA_DIR"); File testDefSourceFile = new File(testDefSource); List<File> testDefFiles = searchFiles(testDefSourceFile, ".*.json"); for (File testDefFile : testDefFiles) { // try { TestCaseModeler modeler; try { modeler = getTestCaseModeler(testDefFile.getAbsolutePath()); } catch (JsonParseException e) { LOG.warn( "Caught exception parsing " + testDefFile + ". This test will not be executed.", e); continue; } List<String> categories = modeler.categories; boolean foundTests = false; for (String testGroup : testGroups) { if (categories != null && !categories.contains(testGroup)) { continue; } else { foundTests = true; break; } } if (!foundTests) { continue; } String queryFileExtension = modeler.matrices.get(0).inputFile; String expectedFileExtension = modeler.matrices.get(0).expectedFile; boolean skipSuite = false; if (modeler.dependencies != null) { for (String dependency : modeler.dependencies) { if (TestDriver.OPTIONS.excludeDependenciesAsList().contains(dependency)) { skipSuite = true; } } } if (skipSuite) { continue; } List<File> testQueryFiles = searchFiles(testDefFile.getParentFile(), queryFileExtension); for (File testQueryFile : testQueryFiles) { String expectedFileName = getExpectedFile( testQueryFile.getAbsolutePath(), queryFileExtension, expectedFileExtension); drillTestCases.add( new DrillTestCase(modeler, testQueryFile.getAbsolutePath(), expectedFileName)); } } } if (drillTestCases.size() == 0) { LOG.warn("Warning: No test cases have been collected."); } return drillTestCases; }