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
How to mockout servicecall in jasmine test?
I created an angular custom directive with a service called scriptingService in it. The goal is to mock the service call out with a spyOn. This is part of the test:
beforeEach(inject(function ($rootScope, $compile,_scriptingService_) {
scope…

bier hier
- 20,970
- 42
- 97
- 166
0
votes
2 answers
AngularJSUnitTesting : Expected spy function() to have been called
Below is my code , I dont want the service function to be invoked so I am using spy, but its giving error.I am not able to figure it out.
'use strict';
describe('Testing DetailCtrl\n\n\n', function() {
beforeEach(module("safe-repository"));
…

shreyansh
- 1,637
- 4
- 26
- 46
0
votes
1 answer
spyOn function in Jasmine that returns random element from array
I am currently building a Rock, Paper, Scissors game in Javascript and using TDD to guide my code. I am trying to run a Jasmine test that forces one of my functions to return a set value. I want my "compChoice" function to return a random element…

Adrian Booth
- 49
- 1
- 4
0
votes
1 answer
How to use Silverlight spy tool with Selenium WebDriver
I have downloaded free version of silverlight spy tool to capture object defitions of silverlight controls. I want to use these definitions into my script which I am executing using selenium web driver.
Could anyone help me on how to capture object…

Amol Chitte
- 21
- 1
- 2
0
votes
1 answer
Arquillian and method execution verification
I'm running my .ear in container running arquillian. I'm testing some communication with external system, so I have created simulator for that system.
I want to be able to check the format of passed messages. How should I do it?
Should I put asserts…

Zveratko
- 2,663
- 6
- 35
- 64
0
votes
1 answer
Greater weight to smaller values using `spy` in Matlab?
I'm new to MatLab and I have a table of a few hundred variables. I know that the smaller variables hold greater significance than the larger variables in that table and want the sparse matrix I graph to illustrate this. Not so much lim approaches 0…

jake mckenzie
- 1,246
- 2
- 8
- 9
0
votes
1 answer
Mockito - right way to test a method with params
I need your assistance please:
I have this method:
public class MyTestClass {
protected void foo(JSONObject result, String text){
String userId = result.optString("name");
mApi.sendInfo(userId, text, mListener);
}
}
In Mockito…

Alon Minski
- 1,571
- 2
- 19
- 32
0
votes
1 answer
Junit Mocking of 2 methods
This the definition of my class:
class A
{
public b method1()
{
//some code
}
}
class Z
{
A a = new A();
public c method2()
{
z = a.method1();
//some code validating z
}
}
I want to test method2…

Nissan Modi
- 1
- 1
0
votes
0 answers
Using test spy to record REST requests and reponse
I am trying to use sinon.spy to record calls
beforeEach:
// Get restify JSON clinet instance
// Using rewire
// m_jsonClient is a private field
m_jsonClient = myMod.__get__('m_jsonClient')
jsonClientGetSpy = sandbox.spy(m_jsonClient, 'get')
it:
…

hellboy
- 1,567
- 6
- 21
- 54
0
votes
1 answer
My Karma spy is not picking up on my controller function
My spec:
describe('ScheduleController', function() {
var ScheduleController, scope, spies = {};
beforeEach(function() {
module('mapApp');
return inject(function($injector) {
var $controller, $rootScope;
…

Shamoon
- 41,293
- 91
- 306
- 570
0
votes
2 answers
Jasmine testing: how to spy on special function?
I am new to Testing, Jasmine and Javascript and maybe this question is trivial. I have to test a function with Jasmine:
define(["module", ...], function(Module, ...){
//...
action: function(){
//...
…

Garrarufa
- 1,145
- 1
- 12
- 29
0
votes
1 answer
Create a spy for a function in a class
I'm adding Jasmine to a large project in order to add tests to that project's javascript. Normally I use Ruby and I'm a little out of my element here.
I have a class, that has a function and I want to create a spy for it so that it returns a certain…

RobertH
- 528
- 3
- 13
0
votes
1 answer
Mocking a void function in Scala with Mockito?
I'm trying to verify that a logger gets called. The problem is that it returns void and so it's recommended that I use a spy instead of a stub. Unfortunately, the spy is acting funky (not working). Ideally, I would also like to remove the "msg" and…

U Avalos
- 6,538
- 7
- 48
- 81
0
votes
1 answer
Mockito tries to invoke method when I set behaviour for it
I have following code line:
when(htmlEmailSpy.setFrom(anyString())).thenReturn(null);
Following code executes real htmlEmailSpy.setFrom(...) but it throws exception.
@Spy
HtmlEmail htmlEmailSpy = new HtmlEmail();
What do I wrong?
my aim - set new…

gstackoverflow
- 36,709
- 117
- 359
- 710
0
votes
1 answer
Spy on a local function Angular Service
I have an Angular Service using a local function and doing the following work:
function myService($http,$q){
var myService = {};
var _localService = function (Table) {
return Table.something;
}
var _getSomething = function () {
return…

Sifis
- 653
- 5
- 18