- var args = splitVariables();
- var test = args.test;
- var command = args.command;
-
- // args.testCaseName uses the string name of the test.
- if (args.testCaseName) {
- var testCases = getAllTestCases();
- name = args.testCaseName;
- for (var idx in testCases) {
- var entry = testCases[idx];
- if (entry.name == args.testCaseName) {
- var prototype = entry.testCase;
- tc = new entry.testCase();
- break;
- }
- }
- } else if (args.testCase) { // The class name of the test.
- name = args.testCase;
- eval("tc = new " + args.testCase + "()");
- }
-
- var results = null;
- // If the test class is defined.
- if (tc != null) {
- if (args.command == "runAllTests") {
- console.log("Running all tests for " + args.testCase);
- results = tc.runAllTests();
- } else if (args.command == "runTest") {
- console.log("Running test " + args.testCase + "." + args.test);
- results = tc.runTest(args.test);
- }
- } else {
- if (args.command == "runAllTests") {
- console.log("Running all tests for all test cases");
- var testCases = getAllTestCases();
- results = {};
- for (var idx in testCases) {
- var entry = testCases[idx];
- var prototype = entry.testCase;
- tc = new entry.testCase();
- results[entry.name] = tc.runAllTests();
- }
- }
- }
- resultsDiv = createResultsDiv();
- var summary = { failed: 0, passed: 0 };
- postResults(results, summary);
- resultsDiv.appendChild(document.createElement("hr"));
- document.getElementById('summary').innerHTML = "(" + summary.failed + " failed, " + summary.passed + " passed)";