A spy is XUnit pattern where you replace the original implementation with a test double to capture the calls on the object. Later in your test you can verify the object under test has made specific calls on that object
Questions tagged [spy]
425 questions
0
votes
1 answer
enableling spyjs code completion in phpstorm
I got the spyjs tracing running in phpstorm. But I am wondering how to enable the code completion from spy-js like it is done in webstorm. See this article here:…

m4lt3
- 465
- 2
- 15
0
votes
1 answer
how can I verify a spy is called with "null" param
I'm trying to run this line:
verify(imagesSorterSpy, atLeast(2)).sortImages(anyList(), null);
to verify this method was called with null as second argument.
but i get this error:
rg.mockito.exceptions.misusing.InvalidUseOfMatchersException:…

Elad Benda
- 35,076
- 87
- 265
- 471
0
votes
1 answer
How to create a spy for jquery invocation `$(some)`?
I define a requirejs module to provide a function to get browser width:
browserTool.js
define(['jquery'], function($) {
return {
getBrowserWidth: function() {
return $(window).width();
}
}
});
Now I want to write…

Freewind
- 193,756
- 157
- 432
- 708
0
votes
1 answer
Are memcached entries saved by the Danga client compatible with the Spy client?
After saving a String value into memcached using the Danga client, I attempted to get the entry using the Spy client. The two String values are not the same. The Danga client retrieves a string with an additional empty char prepended to the…

onejigtwojig
- 4,771
- 9
- 32
- 35
0
votes
2 answers
Mocking a logger.debug() call inside a test method
I have a method I am trying to test, say methodToTest(). Inside this method is a call to what I believe is a Logger variable, like:
logger.debug("this is a logger debug example");
The problem is that the logger variable is declared outside the…

DanGordon
- 671
- 3
- 8
- 26
0
votes
1 answer
XML Schema: element attribute as unique value?
I'm making XSD schema to validate my XML file generated from java. Its about weather and I want to make value inside date unique.

exort
- 13
- 4
0
votes
1 answer
Is it possible to subclass Android apps?
I want to develop a plugin for an existing app, that doesnt support plugins (Whatsapp for example). On a Windows system this would be very easy, since I can subclass and spy on existing window messages or add new ones, making it possibly to alter…

Maestro
- 9,046
- 15
- 83
- 116
0
votes
1 answer
spying on node child_process using jasmine
I am new to nodejs and jasmine. Working on a small project for learning javascript/node and jasmine. I am trying to spy on the object child_process in node and see the method 'spawn' is called with the arguments specified.
The jasmine error reports…

arunbakt
- 3
- 3
0
votes
1 answer
direct access to jQuery widget factory plugin methods
Using the jQuery widget factory, i want to test internally that methods get called. How can I expose those methods to spy on them?
$.widget 'foo',
_init: ->
@_bar()
_bar ->
barSpy = sinon.spy WidgetPluginObject,…

brewster
- 4,342
- 6
- 45
- 67
0
votes
1 answer
How to stub out a controller method called during object construction
I have an AngularJs controller that calls its own refresh() method while it is being constructed. The method in question accesses some template elements that are not present during unit testing.
function ListController($scope) {
/// ...
…

Paul Taylor
- 5,651
- 5
- 44
- 68
0
votes
1 answer
Scrollspy not working
i got this code, and no matter what i do, the scroll spy won't work, can anyone shed some light into it? thanks in advance!

diogo
- 15
- 6
0
votes
2 answers
Test 'done' callback function of a jQuery deferred object with sinon.js
I have this piece of CoffeeScript code in one of my Backbone views:
myMethod: ->
# some code here
$.when(
# ...
).done(
@myCallback
)
and I wanna test that myCallback is called in the done block.
I'm not…

lucke84
- 4,516
- 3
- 37
- 58
0
votes
3 answers
Spy Java Secure Sockets
I would like to know if there is an easy (or hard) way to spy the secure sockets from a java applet ? (without having the source code)
The goal here is to know exactly what for informations send an (very good obfuscated) applet.
I thought i can…

mathieu
- 477
- 3
- 9
-1
votes
1 answer
When clause is throwing NPE when calling the method specified in the behavior
The class that I want to test is structured in the following manner:
public getUrl(final String str1, final String str2, final String str3, final int int1, final String string4) {
//calls getContext();
}
public getUrlAndAppend(final String str1,…

Marcos Guimaraes
- 1,243
- 4
- 27
- 50
-1
votes
1 answer
Spy InputStream.read(byte[] buffer)
I'm trying to create a test where the third request will throw an error and validate the input of the previous ones.
@Test
void sample() throws IOException {
var is = spy(new ByteArrayInputStream(new byte[]{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}));
…

Archimedes Trajano
- 35,625
- 19
- 175
- 265