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
3b5ed009
...
3b5ed00912f36be9a8372264f477ac27feec544d
authored
2012-01-30 19:43:33 +0100
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
refs #46 - added value details to Tester 'fail' event
1 parent
e8e17db0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
13 deletions
modules/tester.js
modules/tester.js
View file @
3b5ed00
...
...
@@ -80,14 +80,14 @@ var Tester = function(casper, options) {
// methods
/**
* Asserts
a condition
resolves to true.
* Asserts
that a condition strictly
resolves to true.
*
* @param Boolean
condition
* @param String message
Test description
* @param Boolean
subject
* @param String message Test description
*/
this
.
assert
=
function
assert
(
condition
,
message
)
{
this
.
assert
=
function
assert
(
subject
,
message
)
{
var
status
=
this
.
options
.
passText
,
eventName
;
if
(
condition
===
true
)
{
if
(
subject
===
true
)
{
eventName
=
'success'
;
style
=
'INFO'
;
this
.
testResults
.
passed
++
;
...
...
@@ -101,7 +101,10 @@ var Tester = function(casper, options) {
type
:
"assert"
,
details
:
"test failed"
,
message
:
message
,
file
:
this
.
currentTestFile
file
:
this
.
currentTestFile
,
values
:
{
subject
:
subject
}
});
casper
.
echo
([
this
.
colorize
(
status
,
style
),
this
.
formatMessage
(
message
)].
join
(
' '
));
};
...
...
@@ -109,28 +112,32 @@ var Tester = function(casper, options) {
/**
* Asserts that two values are strictly equals.
*
* @param Mixed
testValue
The value to test
* @param Mixed
subject
The value to test
* @param Mixed expected The expected value
* @param String message Test description
*/
this
.
assertEquals
=
function
assertEquals
(
testValue
,
expected
,
message
)
{
this
.
assertEquals
=
function
assertEquals
(
subject
,
expected
,
message
)
{
var
eventName
;
if
(
this
.
testEquals
(
testValue
,
expected
))
{
if
(
this
.
testEquals
(
subject
,
expected
))
{
eventName
=
"success"
;
casper
.
echo
(
this
.
colorize
(
this
.
options
.
passText
,
'INFO'
)
+
' '
+
this
.
formatMessage
(
message
));
this
.
testResults
.
passed
++
;
}
else
{
eventName
=
"fail"
;
casper
.
echo
(
this
.
colorize
(
this
.
options
.
failText
,
'RED_BAR'
)
+
' '
+
this
.
formatMessage
(
message
,
'WARNING'
));
this
.
comment
(
' got: '
+
utils
.
serialize
(
testValue
));
this
.
comment
(
' got: '
+
utils
.
serialize
(
subject
));
this
.
comment
(
' expected: '
+
utils
.
serialize
(
expected
));
this
.
testResults
.
failed
++
;
}
this
.
emit
(
eventName
,
{
type
:
"assertEquals"
,
message
:
message
,
details
:
f
(
"test failed; expected: %s; got: %s"
,
expected
,
testValue
),
file
:
this
.
currentTestFile
details
:
f
(
"test failed; expected: %s; got: %s"
,
expected
,
subject
),
file
:
this
.
currentTestFile
,
values
:
{
subject
:
subject
,
expected
:
expected
}
});
};
...
...
@@ -201,7 +208,11 @@ var Tester = function(casper, options) {
type
:
"assertMatch"
,
message
:
message
,
details
:
f
(
"test failed; subject: %s; pattern: %s"
,
subject
,
pattern
.
toString
()),
file
:
this
.
currentTestFile
file
:
this
.
currentTestFile
,
values
:
{
subject
:
subject
,
pattern
:
pattern
}
});
};
...
...
Please
register
or
sign in
to post a comment