mocking Questions
3
Solved
I currently have the following basic Python class that I want to test:
class Example:
def run_steps(self):
self.steps = 0
while self.steps < 4:
self.step()
def step(self):
# some expen...
Uraemia asked 2/6, 2021 at 2:21
5
I am trying to successfully run the boiler place App-test.js test that comes with the react-native installation. I have seen this test work "out of the box" with other projects, however, mine fails...
Selfgratification asked 5/4, 2020 at 13:0
2
When I run single test with go test -run TestNewProbeServiceIsSingleton it passes as expected.
Problem occurs whenever I am trying to test the whole package/app using go test ./... from my project'...
Marta asked 2/8, 2020 at 11:34
3
I have been trying for several hours to test an endpoint of my rest api with Jest, Supertest and Express.
This endpoint is protected by an authentication middleware named "advancedAuthGuard&qu...
3
I am trying to stub the following:
on('complete', function(data){ });
I only want to call the callback if the first parameter is 'complete'.
The function I am testing also contains:
on('error'...
Warrigal asked 14/5, 2012 at 17:23
9
Solved
I’m using Mockito 1.9.5. How do I mock what is coming back from a protected method? I have this protected method …
protected JSONObject myMethod(final String param1, final String param2)
{
…
}
H...
3
Solved
I'm testing python code (A django 3.0.5 project although I don't think it's relevant), but I can't get the functions of my mocked objects to be called. Here is my code:
**myproject.mypackage.myhelp...
Aspirant asked 16/7, 2020 at 8:6
4
Recently I was upgrading my project from JDK 11 to JDK 17. After upgrading, powermock seems to have an issue. While running AUT's , I am getting following error:
java.lang.RuntimeException: PowerMo...
Vickievicksburg asked 9/11, 2021 at 10:3
3
Solved
I want to Unit Test my Controller, but I'm having issues reading values from HttpContext.Session.
I want to mock this piece from my Controller: HttpContext.Session.Get<int>(Foo)
With Mock Ht...
Rocket asked 16/1, 2019 at 12:37
12
Solved
I have this production method:
public boolean onShouldOverrideUrlLoading(String url) {
boolean isConsumed = false;
if (url.contains("code=")) {
Uri uri = Uri.parse(url);
String authCode = uri....
Bandage asked 16/8, 2015 at 13:36
13
I'm writing a Jest mock, but I seem to have a problem when defining a mocked function outside of the mock itself.
I have a class:
myClass.js
class MyClass {
constructor(name) {
this.name = name;...
Jadwiga asked 21/8, 2018 at 23:0
1
I'm facing some problems when trying to inject a bean with the annotation @MockBean inside a Junit test.
As a result I get the real service injected instead of the mocked one, but the weird behavio...
Galiot asked 8/9, 2020 at 14:1
7
6
Solved
I have some code which uses the nodemailer module.
In the router (router.js), I have
const transporter = nodeMailer.createTransport(emailArgs);
Then inside the route (/login) I have:
...
retur...
Quern asked 21/11, 2018 at 21:14
4
I'm trying to understand the logic of mocking the Vue-Router with Vitest.
For this, I tried to set up and mock my test environment on a very simple project. When I tried to proceed according to the...
Idioblast asked 26/10, 2022 at 13:56
3
Solved
Let's say there's an interface with a callback:
interface SomeInterface {
fun doSomething(arg: String, callback: (Exception?, Long) -> Unit)
}
which I extend into a suspend function like thi...
Overcritical asked 3/8, 2018 at 13:16
3
I want to make the following work, but I don't know how to mock forEach behavior properly. (The code is taken from a related question Testing Java enhanced for behavior with Mockito )
@Test
public...
3
Solved
It seems that for some reason, Microsoft has created an interface for it's messenger and then gone and implemented the logic as extension methods on the interface itself.
Unfortunately, I cannot us...
11
Solved
I'm stuck trying to mock some stuff with mockk:
I have the following setup on gradle
root:
|-- App (just a sample app for the SDK)
|-- SDK (SDK we develop) << apply plugin: 'com.android.l...
5
Solved
How do you use the @patch decorator to patch the built-in input() function?
For example, here's a function in question.py that I'd like to test, which contains a call to input():
def query_yes_no...
Deliciadelicious asked 10/8, 2013 at 11:16
4
Solved
I want to call my mocked method twice with different expected arguments. This doesn't work because expects($this->once()) will fail on the second call.
$mock->expects($this->once())
->...
8
Solved
I got the following method:
private MessageDigest getMessageDigest() {
try {
return MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new Error(e);
}
}
To get 1...
Avila asked 18/5, 2011 at 23:11
8
I have a list like following in config.json file
`
{
"foo": {
"bar": [
"1",
"2",
"3"
]
}
}`
I am able to get the list at run-time using
Configuration.GetSection("foo:bar").Get<List&l...
Unbuild asked 6/5, 2018 at 15:46
3
Solved
Looking at this webpage: http://www.toptal.com/python/an-introduction-to-mocking-in-python -- The author talks about Mocking and Patching in Python and gives a pretty solid "real-world" example. Th...
Gaselier asked 26/10, 2015 at 19:17
2
Solved
I'm writing tests for my Flask project, and are trying to mock my database model. The code looks something like this:
import unittest.mock
@unittest.mock.patch("server.models.user")
def test_that...
Marinemarinelli asked 19/9, 2018 at 11:16
1 Next >
© 2022 - 2024 — McMap. All rights reserved.