8000 Update report structure · browserstack/browserstack-runner@87f4392 · GitHub
[go: up one dir, main page]

Skip to content

Commit 87f4392

Browse files
committed
Update report structure
1 parent 43c2b6e commit 87f4392

File tree

7 files changed

+232
-174
lines changed

7 files changed

+232
-174
lines changed

README.md

Lines changed: 104 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# BrowserStack Runner
2+
3+
[![Build Status](https://travis-ci.org/browserstack/browserstack-runner.svg?branch=master)](https://travis-ci.org/browserstack/browserstack-runner)
4+
15
A command line interface to run browser tests over BrowserStack.
26

37
## Usage
@@ -28,7 +32,6 @@ Where `[user]` is replaced with a local user with enough permissions.
2832
```node
2933
var browserstackRunner = require('browserstack-runner');
3034

31-
global.logLevel = 'info';
3235
var config = require('./browserstack.json');
3336

3437
browserstackRunner.run(config, function(error, report) {
@@ -42,76 +45,115 @@ browserstackRunner.run(config, function(error, report) {
4245
```
4346

4447
The callback to `browserstackRunner.run` is called with two params -
45-
1. `error`: This parameter is either `null` or an `Error` object (if test execution failed) with message as the reason of why executing the tests on `BrowserStack` failed.
46-
2. `report`: This is an object which can be used to keep track of the `failed assertions` and the total count of `passed/failed` tests specific to a browser instance.
48+
- `error`: This parameter is either `null` or an `Error` object (if test execution failed) with message as the reason of why executing the tests on `BrowserStack` failed.
49+
- `report`: This is an array which can be used to keep track of the executed tests and suites in a run. Each object in the array has the following keys -
50+
- `browser`: The name of the browser the test executed on.
51+
- `tests`: An array of `Test` objects. The `Test` Objects are described [here](https://github.com/js-reporters/js-reporters#event-data)
52+
- `suites`: A global Suite Object as described [here](https://github.com/js-reporters/js-reporters#event-data)
4753

4854
The structure of the `report` object is as follows -
4955

5056
```json
51-
{
52-
"OS X Lion, Firefox 44.0": {
53-
"assertions": [
54-
{
55-
"actual": false,
56-
"expected": true,
57-
"message": "One is an odd number",
58-
"source": "@http://localhost:8888/tests/test.js:4:1"
59-
},
60-
{
61-
"actual": false,
62-
"expected": true,
63-
"message": "Zero is not odd number",
64-
"source": "@http://localhost:8888/tests/test.js:6:3"
65-
},
66-
{
67-
"actual": false,
68-
"expected": true,
69-
"message": "Three is an odd number",
70-
"source": "@http://localhost:8888/tests/test.js:5:1"
71-
}
72-
],
73-
"tests": [
57+
[
58+
{
59+
"browser": "Windows 7, Firefox 47.0",
60+
"tests": [
7461
{
75-
"runtime": 3,
76-
"total": 1,
77-
"passed": 0,
78-
"failed": 1,
79-
"url": "/sample.html"
62+
"name": "isOdd()",
63+
"suiteName": "Odd Tests",
64+
"fullName": [
65+
"Odd Tests",
66+
"isOdd()"
67+
],
68+
"status": "passed",
69+
"runtime": 2,
70+
"errors": [],
71+
"assertions": [
72+
{
73+
"passed": true,
74+
"actual": true,
75+
"expected": true,
76+
"message": "One is an odd number"
77+
},
78+
{
79+
"passed": true,
80+
"actual": true,
81+
"expected": true,
82+
"message": "Three is an odd number"
83+
},
84+
{
85+
"passed": true,
86+
"actual": true,
87+
"expected": true,
88+
"message": "Zero is not odd number"
89+
}
90+
]
8091
}
81-
]
82-
},
83-
"OS X Mountain Lion, Chrome 49.0": {
84-
"assertions": [
85-
{
86-
"actual": false,
87-
"expected": true,
88-
"message": "Three is an odd number",
89-
"source": " at Object.<anonymous> (http://localhost:8888/tests/test.js:5:10)"
90-
},
91-
{
92-
"actual": false,
93-
"expected": true,
94-
"message": "One is an odd number",
95-
"source": " at Object.<anonymous> (http://localhost:8888/tests/test.js:4:10)"
96-
},
97-
{
98-
"actual": false,
99-
"expected": true,
100-
"message": "Zero is not odd number",
101-
"source": " at Object.<anonymous> (http://localhost:8888/tests/test.js:6:10)"
102-
}
103-
],
104-
"tests": [
92+
],
93+
"suites": {
94+
"fullName": [],
95+
"childSuites": [
10596
{
106-
"runtime": 9,
107-
"total": 1,
108-
"passed": 0,
109-
"failed": 1,
110-
"url": "/sample.html"
97+
"name": "Odd Tests",
98+
"fullName": [
99+
"Odd Tests"
100+
],
101+
"childSuites": [],
102+
"tests": [
103+
{
104+
"name": "isOdd()",
105+
"suiteName": "Odd Tests",
106+
"fullName": [
107+
"Odd Tests",
108+
"isOdd()"
109+
],
110+
"status": "passed",
111+
"runtime": 2,
112+
"errors": [],
113+
"assertions": [
114+
{
115+
"passed": true,
116+
"actual": true,
117+
"expected": true,
118+
"message": "One is an odd number"
119+
},
120+
{
121+
"passed": true,
122+
"actual": true,
123+
"expected": true,
124+
"message": "Three is an odd number"
125+
},
126+
{
127+
"passed": true,
128+
"actual": true,
129+
"expected": true,
130+
"message": "Zero is not odd number"
131+
}
132+
]
133+
}
134+
],
135+
"status": "passed",
136+
"testCounts": {
137+
"passed": 1,
138+
"failed": 0,
139+
"skipped": 0,
140+
"total": 1
141+
},
142+
"runtime": 2
111143
}
112-
]
144+
],
145+
"tests": [],
146+
"status": "passed",
147+
"testCounts": {
148+
"passed": 1,
149+
"failed": 0,
150+
"skipped": 0,
151+
"total": 1
152+
},
153+
"runtime": 2
113154
}
114-
}
155+
}
156+
]
115157
```
116158

117159
## Configuration

bin/cli.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function terminateAllWorkers(callback) {
6565
function cleanUpAndExit(signal, error, report, callback) {
6666
ConfigParser.finalBrowsers = [];
6767
callback = callback || function() {};
68-
report = report || {};
68+
report = report || [];
6969
logger.trace('cleanUpAndExit: signal: %s', signal);
7070

7171
try {
@@ -306,8 +306,8 @@ var statusPoller = {
306306
}
307307

308308
logger.trace('[%s] worker.activityTimeout: all tests done', worker.id, config.status && 'with failures');
309-
if(server && server.report) {
310-
callback(null, server.report);
309+
if(server && server.reports) {
310+
callback(null, server.reports);
311311
} else {
312312
callback(null, {});
313313
}
@@ -336,8 +336,8 @@ var statusPoller = {
336336
}
337337

338338
logger.trace('[%s] worker.testActivityTimeout: all tests done', worker.id, config.status && 'with failures');
339-
if(server && server.report) {
340-
callback(null, server.report);
339+
if(server && server.reports) {
340+
callback(null, server.reports);
341341
} else {
342342
callback(null, {});
343343
}

lib/_patch/reporter.js

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
(function() {
22
var runner;
3-
var total = 0,
4-
passed = 0,
5-
failed = 0;
63

74
if (window.QUnit) {
85
runner = new JsReporters.QUnitAdapter(QUnit);
@@ -15,34 +12,13 @@
1512
}
1613

1714
runner.on('testEnd', function(test) {
18-
total = total + 1
19-
20-
passed = passed + (test.status === 'passed' ? 1 : 0);
21-
failed = failed + (test.status === 'failed' ? 1 : 0);
22-
23-
test.errors.forEach(function(error) {
24-
BrowserStack.post("/_progress", {
25-
tracebacks: [{
26-
actual: error.actual,
27-
expected: error.expected,
28-
message: error.message,
29-
source: error.source || error.stack,
30-
testName: test.testName
31-
}]
32-
}, function() {});
15+
BrowserStack.post("/_progress", {
16+
test: test
3317
});
3418
});
3519

3620
runner.on('runEnd', function(globalSuite) {
37-
var results = {};
38-
39-
results.runtime = globalSuite.runtime;
40-
results.total = total;
41-
results.passed = passed;
42-
results.failed = failed;
43-
results.url = window.location.pathname;
44-
45-
BrowserStack.post("/_report", results, function() {});
21+
BrowserStack.post("/_report", globalSuite, function() {});
4622
});
4723
})();
4824

lib/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ exports.config = function(config) {
4444
fallback_project = 'Anonymous OpenSource Project';
4545
}
4646

47-
this.project = process.env.TRAVIS_REPO_SLUG || package_json.name;
47+
this.project = process.env.TRAVIS_REPO_SLUG || fallback_project || package_json.name;
4848
}
4949

5050
var commit_id = process.env.TRAVIS_COMMIT;

0 commit comments

Comments
 (0)
0