Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
3bb07c1d
...
3bb07c1d1fcbbc20b86160d723265d62293a803c
authored
2012-12-16 16:44:53 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added test suite duration to result bar
1 parent
8cd8607a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
16 deletions
modules/tester.js
modules/utils.js
modules/xunit.js
modules/tester.js
View file @
3bb07c1
...
...
@@ -1003,8 +1003,9 @@ Tester.prototype.renderResults = function renderResults(exit, status, save) {
statusText
=
this
.
options
.
passText
;
style
=
'GREEN_BAR'
;
}
result
=
f
(
'%s %s tests executed, %d passed, %d failed.'
,
statusText
,
total
,
this
.
testResults
.
passed
,
this
.
testResults
.
failed
);
result
=
f
(
'%s %s tests executed in %ss, %d passed, %d failed.'
,
statusText
,
total
,
utils
.
ms2seconds
(
this
.
calculateSuiteDuration
()),
this
.
testResults
.
passed
,
this
.
testResults
.
failed
);
}
this
.
casper
.
echo
(
result
,
style
,
this
.
options
.
pad
);
if
(
this
.
testResults
.
failed
>
0
)
{
...
...
modules/utils.js
View file @
3bb07c1
...
...
@@ -495,6 +495,18 @@ function mergeObjects(origin, add) {
exports
.
mergeObjects
=
mergeObjects
;
/**
* Converts milliseconds to seconds and rounds the results to 3 digits accuracy.
*
* @param Number milliseconds
* @return Number seconds
*/
function
ms2seconds
(
milliseconds
)
{
"use strict"
;
return
Math
.
round
(
milliseconds
/
1000
*
1000
)
/
1000
;
}
exports
.
ms2seconds
=
ms2seconds
;
/**
* Creates an (SG|X)ML node element.
*
* @param String name The node name
...
...
modules/xunit.js
View file @
3bb07c1
...
...
@@ -34,17 +34,6 @@ var utils = require('utils');
var
fs
=
require
(
'fs'
);
/**
* Returns duration in seconds, matching XUnit "standard".
*
* @param Number duration Duration in milliseconds
* @return String
*/
function
format_duration
(
duration
)
{
"use strict"
;
return
(
duration
/
1000
).
toString
();
}
/**
* Generates a value for 'classname' attribute of the JUnit XML report.
*
* Uses the (relative) file name of the current casper script without file
...
...
@@ -112,7 +101,7 @@ XUnitExporter.prototype.addSuccess = function addSuccess(classname, name, durati
name
:
name
});
if
(
duration
!==
undefined
)
{
snode
.
setAttribute
(
'time'
,
format_duration
(
duration
));
snode
.
setAttribute
(
'time'
,
utils
.
ms2seconds
(
duration
));
}
this
.
_xml
.
appendChild
(
snode
);
};
...
...
@@ -133,7 +122,7 @@ XUnitExporter.prototype.addFailure = function addFailure(classname, name, messag
name
:
name
});
if
(
duration
!==
undefined
)
{
fnode
.
setAttribute
(
'time'
,
format_duration
(
duration
));
fnode
.
setAttribute
(
'time'
,
utils
.
ms2seconds
(
duration
));
}
var
failure
=
utils
.
node
(
'failure'
,
{
type
:
type
||
"unknown"
...
...
@@ -151,7 +140,7 @@ XUnitExporter.prototype.addFailure = function addFailure(classname, name, messag
XUnitExporter
.
prototype
.
setSuiteDuration
=
function
setSuiteDuration
(
duration
)
{
"use strict"
;
if
(
!
isNaN
(
duration
))
{
this
.
_xml
.
setAttribute
(
"time"
,
format_duration
(
duration
));
this
.
_xml
.
setAttribute
(
"time"
,
utils
.
ms2seconds
(
duration
));
}
};
...
...
Please
register
or
sign in
to post a comment