121 questions
0
votes
0
answers
154
views
Rspec expectation error: reading hash argument as keyword arguments
I'm in the middle of an update to Rails 7.1.3 and I've run into an interesting issue.
I have an initialize which has one positional argument (which defaults to an empty hash) and some keyword ...
0
votes
0
answers
77
views
Gmock: is it allowed to interleave expectations and calls to mock function for Different mock objects?
By the link https://github.com/google/googletest/blob/main/docs/gmock_for_dummies.md#using-mocks-in-tests it's written:
Important note: gMock requires expectations to be set before the mock functions ...
0
votes
0
answers
49
views
How to deal with Unsync Tables in databricks notebooks
So, my question is: i have a bronze - silver injestion, and later this data will be consumed by gold notebooks, i wan't to check if all tables that notebooks uses is updated.
What i thinked, use dlt ...
0
votes
0
answers
117
views
Is it possible to calculate an exact/approximate expectation over an argmax function of a random variable?
given a non-increasing vector $b\in R^n$ I would like to calculate the expected argmax of the function f(b) = i*b_i.
More clear and mathematical meaning.
It's worth mentioning that I assume that the ...
0
votes
1
answer
40
views
Dot-notation not working with MixtureExpectation?
This is my first post so I apologize for any formatting issues.
I'm trying to calculate the expected value of a collection of numbers in Julia, given a probability distribution that is the mixture of ...
0
votes
1
answer
71
views
Jmockit StrictExpectations mocking unmocked static method
I am new to jmockit and StrictExpectations. Inside StrictExpectations I have recorded invocation and return value of static method of non-mocked class and the static method is mocked correctly but I ...
-1
votes
1
answer
470
views
Single global instance for multiple test cases in unit testing
I want to setup a global instance variable for all the test cases. Currently I could setup the variable for one test case but it is not set for the other. Mentioned below is my setup code.
func ...
-1
votes
1
answer
40
views
probability , expectations in $L^1$
I found this in another language. I am wondering if anyone could find this in a English book please. Or if anyone know how to prove this please. Preferably one could tell me a reference book. Thank ...
0
votes
1
answer
516
views
Creating Expectations for all columns of certain type in Palantir Foundry
I use a expectations and Check to determine if a column of decimal type could be transformed into int or long type. A column could be safely transformed if it contains integers or decimals where ...
0
votes
0
answers
29
views
Best way of testing randomized function
Let's say I have a random number generator for 3 categories:
Prob
Yield
0.1
10
0.2
5
0.7
2
The expected yield is 1 + 1 + 1.4 = 3.4
Currently I have something like this
sum = 0
N = 10000
for i in ...
0
votes
1
answer
1k
views
Find unbiased estimator for (1+λ)e−λ in a poisson distribution
My Attempt:
I tried using the MLE of λ which I find the sample mean. Then using the invariance property and it follows that (1+X¯)e^−X¯will be the MLE of (1+λ)e^−λ but I'm not sure if it is also ...
4
votes
1
answer
2k
views
XCTWaiter().wait with XCTestExpectation and NSPredicate seems to fail
I am trying to write unit tests where I want my test case to wait for a variable in a certain class to change. So I create an expectation with a predicate and wait for the value to change using ...
0
votes
1
answer
130
views
unit testing iOS function with dispatch
I'm working with unit testing for the first time and I'm lost with some specific cases.
Despite reading a lot I'm confused about how to test a function like this in iOS:
func myFunction() {
...
0
votes
0
answers
123
views
How to estimate this expectation involving two binomial random variables?
X and Y are two independent binomial random variables where X~ B(K_1, q), Y~ B(K_0, p), (Note: p+q is not necessarily equal to 1). I am wondering how to compute the following expectation (the ...
0
votes
0
answers
278
views
A question about the realization and randomness
I am doing an assignment for my data class and new to R programming. If a fair 6-sided die is rolled, Let X be the number showing on the top of the die. (The first question is involved the R ...
1
vote
1
answer
314
views
Expectation of a product in python sympy
In python sympy I have the following code
from sympy.stats import P, E, variance, covariance, Normal
mu, sigma = symbols('mu sigma')
epsilon_t = Normal('epsilon_t', 0, sigma)
epsilon_t1 = Normal('...
1
vote
2
answers
10k
views
queryStringParameters in mock-server
I have the following url:
http://10.11.100.163:1080/v1/publish/?category=conf&product=UFED_INFIELD&serial=123&productGUIDs%5B0%5D%5Bproduct%5D=GLOBAL&productGUIDs%5B0%5D%5Bguid%5D=...
0
votes
1
answer
896
views
Issue with NonStrictExpections to Expectations conversion in junit test cases
Here is my sample code example, which starts failing when I made jmockit update related changes.
class A {
public static boolean validate(String name, int age, boolean flag) {
boolean ...
1
vote
0
answers
504
views
JMockit mock constructor in Expectations
I'm trying to set a result on a constructor call in an Expectations block, but the constructor call in the tested code doesn't return the result I'm setting. There must be a different way to do this, ...
0
votes
2
answers
160
views
Program is not throwing ArgumentOutOfRange Exception
I have a simple program that takes a number from the user and returns the number located at that position/index in an array. However, if the given number is not withing the index range, it throws an ...
0
votes
1
answer
298
views
Does Serverspec support expectations or do I have to use should?
I hear I should be using expectations rather than "should" statements in Serverspec
I have been Googling around for expectations that can be used for file matching but all of the tutorials I see for ...
3
votes
0
answers
867
views
Clear JMockit expectations after a test or a testclass
We are having an old codebase with few tests mocking global static object. That influences other tests that fail if being called in a same testsuite (the same JVM) after the test which mocks static ...
0
votes
3
answers
1k
views
How can we mock scala method with generic return type and implicit parameters?
I have a configuration fetcher that looks something like this.
def getForCountry[A](path: String, fallbackToDefault: Boolean)
(implicit loader: ConfigLoader[A], ac: AppContext): A =...
1
vote
0
answers
280
views
Jmockit How to match 'any' parameter type for Class<T> clazz
Using jmockit, i am creating new expectation
new Expectations(){{
ConfigurationService.get(anyString,****);
}};
of static method
public static <T> T get(String key, Class<...
0
votes
1
answer
553
views
Unable to parse expectation on mockserver-netty when adding Content-Type header
I have an integration test where I am using mockserver-netty (v5.3.0) with a springboot 2.0 application..everything is working fine but if I try to add the Content-Type header, I get the following ...
0
votes
1
answer
195
views
How can I set jmockit expectations for a chain of calls using times?
I am testing a class instance called server and I am using partial mocking, like this:
new Expectations(server) {{
server.readPortNumber(withInstanceOf(File.class));
result = new ...
0
votes
0
answers
69
views
Does expected value of F(x)/x(1-F(x)) have a name, F(x) is CDF? Is it related to hazard function?
I was solving a problem and encountered the following:
\sum (f(x)/x) (F(x)/(1-F(x))
Here f(x) is pmf and F(x) is CDF. Is expected value of F(x)/x(1-F(x)) a known function? I found out that f(x)/(1-F(...
0
votes
0
answers
87
views
Expectations, covariances and correlations
This is the question I am trying to solve. Create a sample of 10,000 pairs (X,Y). Using the above facts, estimateE(X), E(X^2), E(Y ), E(Y^2) and E(XY ) from your sample of data. Hence, compute an ...
1
vote
1
answer
2k
views
Why don't array include checks work as expected in chai.js?
I'm using chai.js expectations with the mocha JS test framework. I'm trying to test inclusion of objects in arrays but it appears the includes behavior supported by chai in their documentation doesn't ...
1
vote
3
answers
2k
views
Java Mockito when accept arguments but conditionally
I am writing a test case using Mockito, and have to write expectation for a method (signature shown below)
public Object process(Employee e);
In my test class, I have to simulate my expectations as ...
8
votes
1
answer
11k
views
Jasmine : spy on a function called X times, and get the n-th call
I can't seem to find a solution online.
Here is a sample of code so you get the issue :
// Spy on the wanted function
spyOn(object, 'myFunction');
// Call it 3 times with different parameters
...
0
votes
0
answers
99
views
R: Difference in expected values of empirical distributions - functional forms unknown
Given a generated two empirical distributions
I am trying to find the expected value of each distribution and then take the difference between these two expected values.
Most questions that I have ...
0
votes
0
answers
404
views
Moq setup does not match parameter because it is a subtype?
I'm trying to use Setup on a Moq like I've done many times to return a value, but I can't seem to understand why the parameter matching fails in this case.
Here's what I'm doing:
var myParameter = ...
0
votes
2
answers
875
views
JMockit is not instantiating captured interfaces in Expectations block
I'm not sure whether I'm using JMockit incorrectly, or there's something amiss in my setup. I'm using JMockit 1.32 with JUnit 4.12 in Eclipse.
My problem seems to be that interfaces aren't being ...
8
votes
3
answers
11k
views
c++ gtest print additional information in the end of a test when and only when the test fails
I want to do somethink like this:
TEST(MyTestFixture, printAfterExpectationFailure)
{
const string request("bring me tea");
const string&& response = sendRequestAndGetResponse(request);
...
0
votes
1
answer
184
views
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 ...
13
votes
2
answers
4k
views
Interleaving EXPECT_CALL()s and calls to the mock functions
The Google Mock documentation says:
Important note: Google Mock requires expectations to be set before the mock functions are called, otherwise the behavior is undefined. In particular, you mustn't ...
0
votes
1
answer
592
views
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 ...
1
vote
1
answer
2k
views
IllegalArgumentException: Invalid conditional statement inside expectation block
I have a problem with an Expectations block I have written in my test case:
new Expectations() {
{
mFindHandlerMock.findAll((Model) any, (Set<Id>) any, false);
if (!...
0
votes
2
answers
434
views
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();
...
0
votes
1
answer
65
views
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' ...
1
vote
3
answers
21k
views
java.lang.Exception: Test class should have exactly one public zero-argument constructor:
I have a class : Function Library where I am instantiating the webdriver instance in constructor as below
public class FunctionLibrary {
public WebDriver driver;
public FunctionLibrary(...
3
votes
1
answer
4k
views
JMockit - Expectations - matching invocation of method that includes mocked object as argument
I am using JMockit to test an application (Java 8, Junit 4.12, JMockit 1.17).
I have some code which is supposed to upload some data to a list of endpoints.
The class that actually performs an ...
1
vote
0
answers
58
views
Is there a way to find unused expectations in jMock?
We use jMock for a lot of our Java tests. In some test classes, most of the tests work the same way, so common expectations end up in a setUp() method.
Quite often, some of the expectations in the ...
0
votes
0
answers
541
views
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<Object[]> data() {
...
4
votes
1
answer
278
views
How to implement fixtures in clojure expectations?
I have recently started using the Clojure test framework expectations. As part of my test, I have a data set that I want to reset to its original value before the start of a new test/expect statement.
...
1
vote
1
answer
934
views
JMockit mock returns String instead of the List<String> provided
Granted, it's been a while since I used JMockit, but I don't remember this kind of difficulty. I have a very simple test of some very simple code. But even though I set returns = List, the mocked ...
0
votes
0
answers
179
views
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 ...
1
vote
1
answer
2k
views
JMock expectations oneOf VS one difference
Is any difference in using one() or oneOf() in JMock?
Cheat sheet says that:
oneOf = The invocation is expected once and once only.
exactly(n).of = The invocation is expected exactly n times. Note: ...
0
votes
1
answer
891
views
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 ...