Namespace: CoreTest
CoreTest is the unit testing library for SproutCore. It includes a test runner based on QUnit with some useful extensions for testing SproutCore- based applications.
You can use CoreTest just like you would use QUnit in your tests directory.
Defined in: core.js
Field Summary
Class Methods
- argumentsArray(args)
- beget(obj)
- defaultPlan()
- dump(obj, type)
- fmt(str)
- K()
- mixin(target, properties)
- Spy()
- spyOn(object, method)
- Stub()
- stub(name, func)
- stubMethod(object, method)
Field Detail
CoreTest.equivTests for equality any JavaScript type and structure without unexpected results.
Discussions and reference: http://philrathe.com/articles/equiv Test suites: http://philrathe.com/tests/equiv Author: Philippe Rathé prathe@gmail.com
Defined in: equiv.js.
- Since:
- SproutCore 1.0
Class Method Detail
- Parameters:
- args
- Parameters:
- obj
- {Object} the object to beget
- Returns:
- Object
- the new object.
Defined in: plan.js.
Defined in: dump.js.
- Parameters:
- obj
- type
- Parameters:
- str
- Parameters:
- target
- {Object} the target object to extend
- properties
- {Object} one or more objects with properties to copy.
- Returns:
- Object
- the target object.
- Parameters:
- object
- method
Returns a stub function that records any passed arguments and a call count. You can pass no parameters, a single function or a hash.
If you pass no parameters, then this simply returns a function that does nothing but record being called.
If you pass a function, then the function will execute when the method is called, allowing you to stub in some fake behavior.
If you pass a hash, you can supply any properties you want attached to the stub function. The two most useful are "action", which is the function that will execute when the stub runs (as if you just passed a function), and "expect" which should evaluate the stub results.
In your unit test you can verify the stub by calling stub.expect(X), where X is the number of times you expect the function to be called. If you implement your own test function, you can actually pass whatever you want.
Calling stub.reset() will reset the record on the stub for further testing.
- Parameters:
- object
- method