Questions tagged [expectations]

defines a set of expected and/or allowed method/constructor invocations on the mocked types/instances that have been made available to the test through mock fields and/or mock parameters (e.g., in JMockit).

121 questions
0
votes
1 answer

Matlab: Covariance Matrix from matrix of combinations using E(X) and E(X^2)

I have a set of independent binary random variables (say A,B,C) which take a positive value with some probability and zero otherwise, for which I have generated a matrix of 0s and 1s of all possible combinations of these variables with at least a 1…
rock3000
  • 11
  • 1
0
votes
1 answer

How to calculate the expected value of a given distribution in SAS

For example, gamma(2,3) is given. Is there any function in SAS like ExpectedValue("Gamma",2,3) to give the expected value of the distribution. I have googled for a while and no satisfactory answer found.
Sun Dayu
  • 1
  • 1
0
votes
2 answers

JMockit method that isn't mocked doesn't work

Sample class public class Test{ @Tested ClassA objA; @Test(expected = MyException.class){ String expectedVar = "expectedVar"; new Expectations(objA) { { objA.someMethod(); result = expectedVar; } }; // So here is…
Arsen Simonean
  • 362
  • 2
  • 17
0
votes
1 answer

jasmine expect not matching array result

I'm trying the following code: describe("array deletion", function () { it("leaves a hole in middle", function () { var array = ['one','two','three']; delete array[1]; //'two' deleted …
0
votes
0 answers

Jmockit: Mock calls in the @Parameters method

I have a parameterized test class @RunWith(Parameterized.class) class Tests{ private int count; MyClass object; @Parameters public static Collection data() { return Arrays.asList(new Object[][] { {…
deborah-digges
  • 1,165
  • 11
  • 19
0
votes
0 answers

Mathematica Conditional Expectation using Mixture Distribution

I'm using Mathematica to find a closed-form solution for a conditional expectation. The distribution I am interested in is a mixture of two trivariate normals. In particular, I would like to know the conditional expectation of one random variable…
0
votes
1 answer

rspec, validate the actual Expectation parameter

Is it possible to validate the actual parameter received by a mock objects method parameter? I cannot do a direct comparison because i'm using Fabricate and converting the object into a serialised format. for example: expect(user).to…
wired00
  • 13,930
  • 7
  • 70
  • 73
0
votes
1 answer

Expected value of average selling price

I have n items priced P1,P2...Pn. An item will get sold with a probability p. I need to find an expression for the expected value of the average selling price. Since, the items can be sold in 2^n ways,this seems very daunting. My take All items…
kangkan Dc
  • 183
  • 1
  • 9
0
votes
1 answer

PHPunit expectation on Mock object is not fulfilled

Here is my class: public function __construct(Manager $moduleManager, Source\Yesno $yesNo) { $this->moduleManager = $moduleManager; $this->yesNo = $yesNo; } public function my1() { $this->moduleManager->isOutputEnabled(''); …
zhartaunik
  • 932
  • 12
  • 29
0
votes
2 answers

RSpec: Expectation on model's not working while testing controller

I'm trying to write a functional test. My test looks as following: describe PostsController do it "should create a Post" do Post.should_receive(:new).once post :create, { :post => { :caption => "ThePost", :category => "MyCategory" } } …
oldhomemovie
  • 14,621
  • 13
  • 64
  • 99
0
votes
1 answer

How to expect a new arraylist object in powermock?

I have a code which has below two new List objects of different type: List typeOneList = new ArrayList(); List typeTwoList = new ArrayList(); How can I use PowerMock.expectNew() to return two different…
Rajan
  • 124
  • 2
  • 12
0
votes
1 answer

Listing the total sum of all possible sums in a set with constraints

I am keen to find out the following: Given a set with N elements, my friend and I are playing a game.I always make the first move. We can only remove either the first or the last element with 50% chance each.We take alternate turns in the game.If…
chelsea
  • 185
  • 1
  • 10
0
votes
1 answer

Mock a method that will return different results based on the order that it's called

I would like to mock a method that returns A when first called, and B when called the second time, and all subsequent calls to it will return C. I was assuming that I can use $this->any() and $this->at() to get the desired expectation, but it seems…
Xavier_Ex
  • 8,432
  • 11
  • 39
  • 55
0
votes
1 answer

Stopping mocking in Jmockit

I am using JMockit. I am mocking a method. I want that mocked method should be called once after that actual method should be called. I am providing the code I am using. package StopMocking; public class ClassToMock { public int methodToMock() …
Varun
  • 209
  • 2
  • 5
  • 11
0
votes
1 answer

UnexpectedInvocation while mocking a static method call

I am trying to test a static method using JMockit. This method uses a utility class static method. When the test runs, JMockit complains and throws the following exception: Test set: com.company.pkg.subpkg.mylib.test.ServiceCommunicationTest …
sgsi
  • 382
  • 1
  • 8
  • 18
1 2 3
8 9