Skip to content

Commit

Permalink
Merge pull request #27923 from Dilhasha/validation
Browse files Browse the repository at this point in the history
[Testerina] Remove explicit test suite validation
  • Loading branch information
Dilhasha authored Jan 18, 2021
2 parents 2b45289 + ea56566 commit 60c8333
Showing 1 changed file with 0 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.Stack;
import java.util.Vector;
import java.util.concurrent.atomic.AtomicBoolean;
Expand Down Expand Up @@ -106,8 +105,6 @@ public BTestRunner(PrintStream outStream, PrintStream errStream) {
* @param suite test meta data for module
*/
public void runTest(TestSuite suite) {
// validate test suite
validateTestSuite(suite);
int[] testExecutionOrder = checkCyclicDependencies(suite.getTests());
List<Test> sortedTests = orderTests(suite.getTests(), testExecutionOrder);
suite.setTests(sortedTests);
Expand All @@ -123,44 +120,6 @@ private static List<Test> orderTests(List<Test> tests, int[] testExecutionOrder)
return sortedTests;
}

/**
* Resolve function names to {@link TesterinaFunction}s.
*
* @param suite {@link TestSuite} whose functions to be resolved.
*/
private static void validateTestSuite(TestSuite suite) {
Set<String> functionNames = suite.getTestUtilityFunctions().keySet();
for (Test test : suite.getTests()) {
if (test.getBeforeTestFunction() != null) {
if (!functionNames.contains(test.getBeforeTestFunction())) {
String msg = String.format("Cannot find the specified before function : [%s] for testerina " +
"function : [%s]", test.getBeforeTestFunction(), test.getTestName());
throw new BallerinaTestException(msg);
}
}
if (test.getAfterTestFunction() != null) {
if (!functionNames.contains(test.getAfterTestFunction())) {
String msg = String.format("Cannot find the specified after function : [%s] for testerina " +
"function : [%s]", test.getAfterTestFunction(), test.getTestName());
throw new BallerinaTestException(msg);
}
}

if (test.getDataProvider() != null && !functionNames.contains(test.getDataProvider())) {
String dataProvider = test.getDataProvider();
String message = String.format("Data provider function [%s] cannot be found.", dataProvider);
throw new BallerinaTestException(message);
}

for (String dependsOnFn : test.getDependsOnTestFunctions()) {
if (functionNames.stream().noneMatch(func -> func.equals(dependsOnFn))) {
throw new BallerinaTestException("Cannot find the specified dependsOn function : "
+ dependsOnFn);
}
}
}
}

private static int[] checkCyclicDependencies(List<Test> tests) {
int numberOfNodes = tests.size();
int[] indegrees = new int[numberOfNodes];
Expand Down

0 comments on commit 60c8333

Please sign in to comment.