jasmine-headless-webkit/ext/jasmine-webkit-specrunner/ReportFileOutput_test.cpp

89 lines
2.2 KiB
C++
Raw Normal View History

2011-08-30 19:59:09 +00:00
#include <QtTest/QtTest>
#include "ReportFileOutput.h"
#include "ReportFileOutput_test.h"
using namespace std;
ReportFileOutputTest::ReportFileOutputTest() : QObject() {}
void ReportFileOutputTest::testPassed() {
stringstream buffer;
ReportFileOutput output;
output.outputIO = &buffer;
output.passed("test||done||file.js:23");
QVERIFY(buffer.str() == "PASS||test||done||file.js:23\n");
QVERIFY(output.successes.size() == 1);
QVERIFY(output.failures.size() == 0);
}
2011-09-02 14:24:24 +00:00
void ReportFileOutputTest::testFailed() {
stringstream buffer;
ReportFileOutput output;
output.outputIO = &buffer;
output.failed("test||done||file.js:23");
2011-09-02 14:24:24 +00:00
QVERIFY(buffer.str() == "FAIL||test||done||file.js:23\n");
QVERIFY(output.successes.size() == 0);
QVERIFY(output.failures.size() == 1);
}
void ReportFileOutputTest::testErrorLog() {
stringstream buffer;
ReportFileOutput output;
output.outputIO = &buffer;
output.errorLog("JS Error", 23, "file.js");
QVERIFY(buffer.str() == "ERROR||JS Error||file.js:23\n");
}
void ReportFileOutputTest::testConsoleLog() {
stringstream buffer;
ReportFileOutput output;
output.outputIO = &buffer;
output.consoleLog("Console");
QVERIFY(buffer.str() == "CONSOLE||Console\n");
}
void ReportFileOutputTest::testStubMethods() {
stringstream buffer;
ReportFileOutput output;
output.outputIO = &buffer;
output.internalLog("Internal", "Log");
output.logSpecFilename("Filename");
output.logSpecResult("REsult");
}
void ReportFileOutputTest::testReportFailure() {
stringstream buffer;
ReportFileOutput output;
output.outputIO = &buffer;
output.reportFailure("5", "2", "1.5");
QVERIFY(buffer.str() == "TOTAL||5||2||1.5||F\n");
}
void ReportFileOutputTest::testReportSuccess() {
stringstream buffer;
ReportFileOutput output;
output.outputIO = &buffer;
output.reportSuccess("5", "0", "1.5");
QVERIFY(buffer.str() == "TOTAL||5||0||1.5||F\n");
}
void ReportFileOutputTest::testReportSuccessWithJSErrors() {
stringstream buffer;
ReportFileOutput output;
output.outputIO = &buffer;
output.reportSuccessWithJSErrors("5", "0", "1.5");
QVERIFY(buffer.str() == "TOTAL||5||0||1.5||T\n");
}
2011-08-30 19:59:09 +00:00
QTEST_MAIN(ReportFileOutputTest);