Test library for MTS Socket Modem Arduino Shield devices for Multi-Tech Systems

Dependents:   mtsas mtsas mtsas mtsas ... more

Committer:
Mike Fiore
Date:
Thu Jun 25 08:45:51 2015 -0500
Revision:
13:cc03c4e85c69
Parent:
1:42d2b6980cdd
fix whitespace

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mike Fiore 1:42d2b6980cdd 1 #include "TestRunner.h"
Mike Fiore 1:42d2b6980cdd 2
Mike Fiore 1:42d2b6980cdd 3 #include "mbed.h"
Mike Fiore 1:42d2b6980cdd 4 #include "Test.h"
Mike Fiore 1:42d2b6980cdd 5
Mike Fiore 1:42d2b6980cdd 6 using namespace mts;
Mike Fiore 1:42d2b6980cdd 7
Mike Fiore 1:42d2b6980cdd 8 std::vector<TestCollection*> TestRunner::collections;
Mike Fiore 1:42d2b6980cdd 9
Mike Fiore 1:42d2b6980cdd 10 int TestRunner::totalCollections = 0;
Mike Fiore 1:42d2b6980cdd 11 int TestRunner::collectionsFailed = 0;
Mike Fiore 1:42d2b6980cdd 12 int TestRunner::totalTests = 0;
Mike Fiore 1:42d2b6980cdd 13 int TestRunner::totalFailed = 0;
Mike Fiore 1:42d2b6980cdd 14
Mike Fiore 1:42d2b6980cdd 15 void TestRunner::addCollection(TestCollection* collection)
Mike Fiore 1:42d2b6980cdd 16 {
Mike Fiore 1:42d2b6980cdd 17 collections.push_back(collection);
Mike Fiore 1:42d2b6980cdd 18 }
Mike Fiore 1:42d2b6980cdd 19
Mike Fiore 1:42d2b6980cdd 20 void TestRunner::clearCollections()
Mike Fiore 1:42d2b6980cdd 21 {
Mike Fiore 1:42d2b6980cdd 22 collections.clear();
Mike Fiore 1:42d2b6980cdd 23 }
Mike Fiore 1:42d2b6980cdd 24
Mike Fiore 1:42d2b6980cdd 25 void TestRunner::runTests(bool printPassedTests, bool printFailedTests, bool printPassedCollections, bool printFailedCollections)
Mike Fiore 1:42d2b6980cdd 26 {
Mike Fiore 1:42d2b6980cdd 27 totalCollections = 0;
Mike Fiore 1:42d2b6980cdd 28 collectionsFailed = 0;
Mike Fiore 1:42d2b6980cdd 29 totalTests = 0;
Mike Fiore 1:42d2b6980cdd 30 totalFailed = 0;
Mike Fiore 1:42d2b6980cdd 31 Test::printPassed(printPassedTests);
Mike Fiore 1:42d2b6980cdd 32 Test::printFailed(printFailedTests);
Mike Fiore 1:42d2b6980cdd 33 for (int i = 0; i < collections.size(); i++) {
Mike Fiore 1:42d2b6980cdd 34 if (printPassedTests || printFailedTests) {
Mike Fiore 1:42d2b6980cdd 35 printf("---Testing Collection: %s---\n\r", collections[i]->getName().c_str());
Mike Fiore 1:42d2b6980cdd 36 }
Mike Fiore 1:42d2b6980cdd 37 collections[i]->run();
Mike Fiore 1:42d2b6980cdd 38 if (Test::getTotalFailed() == 0) {
Mike Fiore 1:42d2b6980cdd 39 if (printPassedCollections) {
Mike Fiore 1:42d2b6980cdd 40 printf("---Collection [%s] - PASSED---\n\r\n\r", collections[i]->getName().c_str());
Mike Fiore 1:42d2b6980cdd 41 }
Mike Fiore 1:42d2b6980cdd 42 } else {
Mike Fiore 1:42d2b6980cdd 43 totalFailed += Test::getTotalFailed();
Mike Fiore 1:42d2b6980cdd 44 collectionsFailed++;
Mike Fiore 1:42d2b6980cdd 45 if (printFailedCollections) {
Mike Fiore 1:42d2b6980cdd 46 printf("---Collection [%s] - FAILED---\n\r\n\r", collections[i]->getName().c_str());
Mike Fiore 1:42d2b6980cdd 47 }
Mike Fiore 1:42d2b6980cdd 48 }
Mike Fiore 1:42d2b6980cdd 49 totalCollections++;
Mike Fiore 1:42d2b6980cdd 50 totalTests += Test::getTotalTests();
Mike Fiore 1:42d2b6980cdd 51 Test::clearTotals();
Mike Fiore 1:42d2b6980cdd 52 }
Mike Fiore 1:42d2b6980cdd 53 printf("\n\r\n\r");
Mike Fiore 1:42d2b6980cdd 54 printf("----------Test Summary----------\n\r");
Mike Fiore 1:42d2b6980cdd 55 printf("[%d/%d] Collections Passed\n\r", (totalCollections - collectionsFailed), totalCollections);
Mike Fiore 1:42d2b6980cdd 56 printf("[%d/%d] Tests Passed\n\r", (totalTests - totalFailed), totalTests);
Mike Fiore 1:42d2b6980cdd 57 printf("Testing: %s\n\r", !totalFailed ? "SUCCESS!" : "FAILURE...");
Mike Fiore 1:42d2b6980cdd 58 }