Replies: 59 comments 28 replies
|
I think there is a misconception here. You first |
|
Can you explain more what is missing in the execution of the system under test? |
|
Typically |
|
Thank you for clarification. Is that any way I can assert it raises the correct exception like But I got the error |
|
I still think there is something odd here. Are you experienced with mock driven development or TDD etc. ? E.g. For your code, typically the real implementation of I see that the token you instantiate is an invalid token, but it is an instance of |
|
I am not experienced with mock driven development or TDD. My main goal is to test if the input is valid or not. The instance I don't want to execute the code in I am wrong when calling token with a Is it normal if this error occur? |
|
Well now you get the Maybe it looks like: If this is the function under test, then one test could look like: These are just examples. To help you out, you should focus and maybe post the function-under-test. This function uses a dependency ( Everything else, we also have |
|
The function I test is I need to test all the valid inputs, output type is |
|
Ok, when You look at the dependencies: In Make this test somehow pass. It gets easier if the first happy path passes. And from there you test permutations and focus on edge cases and failing inputs. (There is probably already an error in the code as setting dn, sn, and e should throw.) Does this gets you started? |
|
I got the error when running |
|
I thought To get you started I actually wrote it with |
|
Thank you for clarifying that for me. I filled out the json value manually and don't care about the arguments I want to confirm the output of test function, it works. |
|
I also tried to test if exception is raised, the correct message is showed. It works with |
|
I don't see why there should be any difference in the last example: |
|
That works. Thank you !!! |
|
Are you sure you know what you're doing here? 😁
|
And so when I call |
|
So you want to use a |
|
|
|
I don't think you should use It feels brittle to have a plain You can always do to suppress the signature check (which gives you the I don't know why you put this call in the command. |
|
I put Adding |
|
This test should be fail because So I remove
|
|
Idk what's going on here. If result.stdout is a patch you did a |
|
Btw you need to unstub on |
|
I unstub on I tested for the valid case and the output of command is json and I mock the |
|
The code you posted just doesn't match. you mock |
|
I tried with |
|
When you patch |
|
is there any way I can get the json output when I do not patch |
|
Hi,
The test function : But I got the error. Is there any way I can mock this instance ? |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I tried to mock the input type of a function
create_serviceinservices.py.I am setting up a mock with
whenand then usingverifyto evaluate the valid or invalid inputs but I got the following error. Is there any way I can fix the error?mockito.verification.VerificationError: Wanted but not invoked: create_service(<Any: <class 'Token'>>, <Any: <class 'str'>>, None, None, 'p', False) Instead got: NothingAll reactions