[0] | 1 | importPackage(java.lang);
|
---|
| 2 |
|
---|
| 3 | var RhinoReporter = function() {
|
---|
| 4 | /*
|
---|
| 5 | * Reporter which reports the number of //expects// checks which
|
---|
| 6 | * passed/failed at the end of the test run
|
---|
| 7 | */
|
---|
| 8 | return {
|
---|
| 9 | reportRunnerStarting: function(runner) {
|
---|
| 10 | if (EnvJasmine.incrementalOutput) {
|
---|
| 11 | print(EnvJasmine.specFile);
|
---|
| 12 | }
|
---|
| 13 | },
|
---|
| 14 |
|
---|
| 15 | reportRunnerResults: function(runner) {
|
---|
| 16 | var results = runner.results();
|
---|
| 17 |
|
---|
| 18 | if (EnvJasmine.incrementalOutput) {
|
---|
| 19 | var passed = results.passedCount - EnvJasmine.passedCount,
|
---|
| 20 | failed = results.failedCount - EnvJasmine.failedCount,
|
---|
| 21 | total = results.totalCount - EnvJasmine.totalCount;
|
---|
| 22 | print();
|
---|
| 23 | print([
|
---|
| 24 | EnvJasmine[passed ? 'green' : 'plain']("Passed: " + passed),
|
---|
| 25 | EnvJasmine[failed ? 'red' : 'plain']("Failed: " + failed),
|
---|
| 26 | EnvJasmine.plain("Total: " + total)
|
---|
| 27 | ].join(' '));
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | EnvJasmine.passedCount = results.passedCount;
|
---|
| 31 | EnvJasmine.failedCount = results.failedCount;
|
---|
| 32 | EnvJasmine.totalCount = results.totalCount;
|
---|
| 33 | },
|
---|
| 34 |
|
---|
| 35 | reportSuiteResults: function(suite) {
|
---|
| 36 | },
|
---|
| 37 |
|
---|
| 38 | reportSpecStarting: function(spec) {
|
---|
| 39 | },
|
---|
| 40 |
|
---|
| 41 | reportSpecResults: function(spec) {
|
---|
| 42 | if (spec.results().passed()) {
|
---|
| 43 | System.out.print(EnvJasmine.green("."));
|
---|
| 44 | } else {
|
---|
| 45 | var i, msg, result,
|
---|
| 46 | specResults = spec.results().getItems();
|
---|
| 47 |
|
---|
| 48 | System.out.print(EnvJasmine.red("F"));
|
---|
| 49 |
|
---|
| 50 | msg = [
|
---|
| 51 | "FAILED",
|
---|
| 52 | "File : " + EnvJasmine.specFile,
|
---|
| 53 | "Suite: " + this.getSuiteName(spec.suite),
|
---|
| 54 | "Spec : " + spec.description
|
---|
| 55 | ];
|
---|
| 56 |
|
---|
| 57 | for (i = 0; i < specResults.length; i++) {
|
---|
| 58 | result = specResults[i];
|
---|
| 59 | if (result.type == 'log') {
|
---|
| 60 | msg.push(result.toString());
|
---|
| 61 | } else if (result.type == 'expect' && result.passed && !result.passed()) {
|
---|
| 62 | msg.push(result.message);
|
---|
| 63 |
|
---|
| 64 | if (result.trace.stack) {
|
---|
| 65 | msg.push(specResults[i].trace.stack);
|
---|
| 66 | }
|
---|
| 67 | }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | EnvJasmine.results.push(msg.join("\n"));
|
---|
| 71 | }
|
---|
| 72 | },
|
---|
| 73 |
|
---|
| 74 | log: function(str) {
|
---|
| 75 | },
|
---|
| 76 |
|
---|
| 77 | getSuiteName: function(suite) {
|
---|
| 78 | var suitePath = [];
|
---|
| 79 |
|
---|
| 80 | while (suite) {
|
---|
| 81 | suitePath.unshift(suite.description);
|
---|
| 82 | suite = suite.parentSuite;
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | return suitePath.join(' - ');
|
---|
| 86 | }
|
---|
| 87 | };
|
---|
| 88 | };
|
---|
| 89 |
|
---|
| 90 | var RhinoSpecReporter = function() {
|
---|
| 91 | /*
|
---|
| 92 | * Reporter which reports the number of //specs// which passed/failed at the end
|
---|
| 93 | * of the test run
|
---|
| 94 | */
|
---|
| 95 | return {
|
---|
| 96 | reportRunnerStarting: function(runner) {
|
---|
| 97 | if (EnvJasmine.incrementalOutput) {
|
---|
| 98 | print(EnvJasmine.specFile);
|
---|
| 99 | }
|
---|
| 100 | },
|
---|
| 101 |
|
---|
| 102 | reportRunnerResults: function(runner) {
|
---|
| 103 | var results = runner.results();
|
---|
| 104 |
|
---|
| 105 | if (EnvJasmine.incrementalOutput) {
|
---|
| 106 | print();
|
---|
| 107 | print([
|
---|
| 108 | EnvJasmine.green("Passed: " + (results.passedCount - EnvJasmine.passedCount)),
|
---|
| 109 | EnvJasmine.red("Failed: " + (results.failedCount - EnvJasmine.failedCount)),
|
---|
| 110 | EnvJasmine.plain("Total: " + (results.totalCount - EnvJasmine.totalCount))
|
---|
| 111 | ].join(' '));
|
---|
| 112 | }
|
---|
| 113 | },
|
---|
| 114 |
|
---|
| 115 | reportSuiteResults: function(suite) {
|
---|
| 116 | },
|
---|
| 117 |
|
---|
| 118 | reportSpecStarting: function(spec) {
|
---|
| 119 | },
|
---|
| 120 |
|
---|
| 121 | reportSpecResults: function(spec) {
|
---|
| 122 | if (spec.results().passed()) {
|
---|
| 123 | System.out.print(EnvJasmine.green("."));
|
---|
| 124 | EnvJasmine.passedCount += 1;
|
---|
| 125 | } else {
|
---|
| 126 | var i, msg, result,
|
---|
| 127 | specResults = spec.results().getItems();
|
---|
| 128 |
|
---|
| 129 | System.out.print(EnvJasmine.red("F"));
|
---|
| 130 |
|
---|
| 131 | msg = [
|
---|
| 132 | "FAILED",
|
---|
| 133 | "File : " + EnvJasmine.specFile,
|
---|
| 134 | "Suite: " + this.getSuiteName(spec.suite),
|
---|
| 135 | "Spec : " + spec.description
|
---|
| 136 | ];
|
---|
| 137 |
|
---|
| 138 | for (i = 0; i < specResults.length; i++) {
|
---|
| 139 | result = specResults[i];
|
---|
| 140 | if (result.type == 'log') {
|
---|
| 141 | msg.push(result.toString());
|
---|
| 142 | } else if (result.type == 'expect' && result.passed && !result.passed()) {
|
---|
| 143 | msg.push(result.message);
|
---|
| 144 |
|
---|
| 145 | if (result.trace.stack) {
|
---|
| 146 | msg.push(specResults[i].trace.stack);
|
---|
| 147 | }
|
---|
| 148 | }
|
---|
| 149 | }
|
---|
| 150 | EnvJasmine.failedCount += 1;
|
---|
| 151 |
|
---|
| 152 | EnvJasmine.results.push(msg.join("\n"));
|
---|
| 153 | }
|
---|
| 154 | EnvJasmine.totalCount += 1;
|
---|
| 155 | },
|
---|
| 156 |
|
---|
| 157 | log: function(str) {
|
---|
| 158 | },
|
---|
| 159 |
|
---|
| 160 | getSuiteName: function(suite) {
|
---|
| 161 | var suitePath = [];
|
---|
| 162 |
|
---|
| 163 | while (suite) {
|
---|
| 164 | suitePath.unshift(suite.description);
|
---|
| 165 | suite = suite.parentSuite;
|
---|
| 166 | }
|
---|
| 167 |
|
---|
| 168 | return suitePath.join(' - ');
|
---|
| 169 | }
|
---|
| 170 | };
|
---|
| 171 | };
|
---|
| 172 |
|
---|
| 173 |
|
---|