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
2b819b07
...
2b819b07e767bbcffe05d51abf4e5d9e729cef00
authored
2012-12-28 11:10:16 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
added warnings to xunit xml output
1 parent
14a9a8bd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
20 deletions
modules/tester.js
modules/xunit.js
modules/tester.js
View file @
2b819b0
...
...
@@ -161,6 +161,12 @@ var Tester = function Tester(casper, options) {
}
self
.
done
();
});
this
.
casper
.
on
(
'warn'
,
function
(
warning
)
{
if
(
self
.
currentSuite
)
{
self
.
currentSuite
.
addWarning
(
warning
);
}
});
};
// Tester class is an EventEmitter
...
...
@@ -857,16 +863,7 @@ Tester.prototype.done = function done(planned) {
*/
Tester
.
prototype
.
dubious
=
function
dubious
(
planned
,
executed
)
{
"use strict"
;
var
message
=
f
(
'%d tests planned, %d tests executed'
,
planned
,
executed
);
this
.
currentSuite
.
addWarning
({
message
:
message
,
file
:
this
.
currentTestFile
,
values
:
{
planned
:
planned
,
executed
:
executed
}
});
this
.
casper
.
warn
(
message
);
this
.
casper
.
warn
(
f
(
'%d tests planned, %d tests executed'
,
planned
,
executed
));
};
/**
...
...
@@ -1025,7 +1022,6 @@ Tester.prototype.processAssertionResult = function processAssertionResult(result
style
=
'RED_BAR'
;
status
=
this
.
options
.
failText
;
}
style
=
result
.
type
===
"dubious"
?
"WARN_BAR"
:
style
;
this
.
casper
.
echo
([
this
.
colorize
(
status
,
style
),
this
.
formatMessage
(
message
)].
join
(
' '
));
this
.
emit
(
eventName
,
result
);
if
(
this
.
options
.
failFast
&&
!
result
.
success
)
{
...
...
@@ -1040,10 +1036,10 @@ Tester.prototype.processAssertionResult = function processAssertionResult(result
*/
Tester
.
prototype
.
renderFailureDetails
=
function
renderFailureDetails
()
{
"use strict"
;
var
failures
=
this
.
suiteResults
.
getAllFailures
();
if
(
failures
.
length
===
0
)
{
if
(
!
this
.
suiteResults
.
isFailed
())
{
return
;
}
var
failures
=
this
.
suiteResults
.
getAllFailures
();
this
.
casper
.
echo
(
f
(
"\nDetails for the %d failed test%s:\n"
,
failures
.
length
,
failures
.
length
>
1
?
"s"
:
""
),
"PARAMETER"
);
failures
.
forEach
(
function
_forEach
(
failure
)
{
...
...
@@ -1113,11 +1109,9 @@ Tester.prototype.runSuites = function runSuites() {
this
.
loadIncludes
.
includes
.
forEach
(
function
_forEachInclude
(
include
)
{
phantom
.
injectJs
(
include
);
});
this
.
loadIncludes
.
pre
.
forEach
(
function
_forEachPreTest
(
preTestFile
)
{
testFiles
=
testFiles
.
concat
(
preTestFile
);
});
Array
.
prototype
.
forEach
.
call
(
arguments
,
function
_forEachArgument
(
path
)
{
if
(
!
fs
.
exists
(
path
))
{
self
.
bar
(
f
(
"Path %s doesn't exist"
,
path
),
"RED_BAR"
);
...
...
@@ -1128,21 +1122,17 @@ Tester.prototype.runSuites = function runSuites() {
testFiles
.
push
(
path
);
}
});
this
.
loadIncludes
.
post
.
forEach
(
function
_forEachPostTest
(
postTestFile
)
{
testFiles
=
testFiles
.
concat
(
postTestFile
);
});
if
(
testFiles
.
length
===
0
)
{
this
.
bar
(
f
(
"No test file found in %s, aborting."
,
Array
.
prototype
.
slice
.
call
(
arguments
)),
"RED_BAR"
);
this
.
casper
.
exit
(
1
);
}
self
.
currentSuiteNum
=
0
;
self
.
currentTestStartTime
=
new
Date
();
self
.
lastAssertTime
=
0
;
var
interval
=
setInterval
(
function
_check
(
self
)
{
if
(
self
.
running
)
{
return
;
...
...
@@ -1243,6 +1233,20 @@ TestSuiteResult.prototype.countTotal = function countTotal() {
};
/**
* Returns the number of errors.
*
* @return Number
*/
TestSuiteResult
.
prototype
.
countErrors
=
function
countErrors
()
{
"use strict"
;
return
this
.
map
(
function
(
result
)
{
return
result
.
crashed
;
}).
reduce
(
function
(
a
,
b
)
{
return
a
+
b
;
},
0
);
};
/**
* Returns the number of failed tests.
*
* @return Number
...
...
@@ -1271,6 +1275,30 @@ TestSuiteResult.prototype.countPassed = function countPassed() {
};
/**
* Returns the number of warnings.
*
* @return Number
*/
TestSuiteResult
.
prototype
.
countWarnings
=
function
countWarnings
()
{
"use strict"
;
return
this
.
map
(
function
(
result
)
{
return
result
.
warned
;
}).
reduce
(
function
(
a
,
b
)
{
return
a
+
b
;
},
0
);
};
/**
* Checks if the suite has failed.
*
* @return Number
*/
TestSuiteResult
.
prototype
.
isFailed
=
function
isFailed
()
{
"use strict"
;
return
this
.
countErrors
()
+
this
.
countFailed
()
>
0
;
};
/**
* Returns all failures from this suite.
*
* @return Array
...
...
modules/xunit.js
View file @
2b819b0
...
...
@@ -100,10 +100,13 @@ XUnitExporter.prototype.getXML = function getXML() {
var
suiteNode
=
utils
.
node
(
'testsuite'
,
{
name
:
result
.
name
,
tests
:
result
.
assertions
,
failures
:
result
.
failures
.
length
,
failures
:
result
.
failed
,
errors
:
result
.
crashed
,
time
:
utils
.
ms2seconds
(
result
.
calculateDuration
()),
timestamp
:
(
new
Date
()).
toISOString
(),
'package'
:
generateClassName
(
result
.
file
)
});
// succesful test cases
result
.
passes
.
forEach
(
function
(
success
)
{
var
testCase
=
utils
.
node
(
'testcase'
,
{
name
:
success
.
message
||
success
.
standard
,
...
...
@@ -112,6 +115,7 @@ XUnitExporter.prototype.getXML = function getXML() {
});
suiteNode
.
appendChild
(
testCase
);
});
// failed test cases
result
.
failures
.
forEach
(
function
(
failure
)
{
var
testCase
=
utils
.
node
(
'testcase'
,
{
name
:
failure
.
message
||
failure
.
standard
,
...
...
@@ -132,6 +136,18 @@ XUnitExporter.prototype.getXML = function getXML() {
testCase
.
appendChild
(
failureNode
);
suiteNode
.
appendChild
(
testCase
);
});
// errors
result
.
errors
.
forEach
(
function
(
error
)
{
var
errorNode
=
utils
.
node
(
'error'
,
{
type
:
error
.
name
});
errorNode
.
appendChild
(
document
.
createTextNode
(
error
.
stack
?
error
.
stack
:
error
.
message
));
suiteNode
.
appendChild
(
errorNode
);
});
// warnings
var
warningNode
=
utils
.
node
(
'system-out'
);
warningNode
.
appendChild
(
document
.
createTextNode
(
result
.
warnings
.
join
(
'\n'
)));
suiteNode
.
appendChild
(
warningNode
);
this
.
_xml
.
appendChild
(
suiteNode
);
}.
bind
(
this
));
this
.
_xml
.
setAttribute
(
'duration'
,
utils
.
ms2seconds
(
this
.
results
.
calculateDuration
()));
...
...
Please
register
or
sign in
to post a comment