Comments (3)
I propose following implementation of assert method
this.assert = function() {
var success = true;
for(var method in entries) {
var entriesForMethod = entries[method];
entriesForMethod.forEach(function(entry) {
if(!entry.shouldFail && entry.executed == false) {
success = false;
console.error(
"method call for: '" + method + "()' with params: " + getParamString(entry.args) + " was not executed!\n"
);
}
if(entry.shouldFail && entry.executed){
success = false;
console.error(
"method call for: '" + method + "()' with params: " + getParamString(entry.args) + " should not be executed!\n"
);
}
});
}
return success;
};
from nodemock.
Can you please provide the sample code re-generating this?
On Fri, Jan 6, 2012 at 4:47 PM, Jigar Gosar <
[email protected]
wrote:
- I really am missing this feature.
- I have marked a method to fail. And need to assert the fact in test that
that method was never called.- In this particular case, the mock throws an error, but the SUT catches
it, since its running a loop, with try/catch in the loop.- Thus my tests are all passing. :(
- Ideally if assertThrows would throw an exception when any method was
called on mock that was marked for failure, this wouldn't let my test pass.- Is it possible to easily integrate this feature?
thanks.
Reply to this email directly or view it on GitHub:
#14
Arunoda Susiripala
@arunoda http://twitter.com/arunoda
http://gplus.to/arunodahttps://github.com/arunoda
http://www.linkedin.com/in/arunoda
from nodemock.
We've a another method called assertThrows()
mocked.assertThrows();
Same as the mocked.assert() but throws an execption if rules breaks.
See this is what you want
from nodemock.
Related Issues (17)
- A way to mock chains HOT 4
- No way to mock multiply-called method with differing return values HOT 6
- cannot assign a mocked function to a var HOT 2
- mock.assert() does not throw... HOT 7
- mock.assert() expects a method with .fail() to be called. HOT 3
- times() shouldn't be default HOT 9
- Mocking event emitters HOT 3
- How do I mock functions? HOT 1
- fail() throws exception on assertThrows when method was not called HOT 2
- BUG: leaking entry global var HOT 4
- Unit tests are failing HOT 5
- Unit tests should be refactored to test one thing, and have more meaningful names HOT 5
- Assert should throw error to be consistent with rest of methods HOT 2
- When mocking a method more than once (with different set of arguments) second mock invocation does not work HOT 1
- assertThrows should raise a meaningful error message HOT 16
- Enable a name to be assigned to a mock HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodemock.