Skip to main content

All Questions

-1 votes
1 answer
172 views

Efficient way to write test cases depending on a Micro service

I'm very new to microservice architecture. In the Monolithic app structure, it was pretty straightforward to write test cases since everything was in one app. I have a situation where I manage a ...
Koushik Das's user avatar
-1 votes
1 answer
572 views

How to write tests for a class that talks to a server without revealing connection implementation

I'm writing a class that acts as the interface to a server. The interface exposes a way to send messages to the server and pass messages back to the client through a callback. Implementations should ...
cluelessatthis's user avatar
2 votes
3 answers
1k views

Still don't understand when to mock and when not to

I've been trying to understand when to mock and when not to mock, however I'm not able to come up with a consistent guideline and I'm hoping to get some input on the subject. Let's look at the ...
de1337ed's user avatar
  • 175
1 vote
3 answers
1k views

Should I unit test functions internally used by API I expose?

I'm writing a CRUD app in Python that exposes web API. At first I wrote functions for communicating with DB and wrote tests for these functions. def crud(): # do something with db def test_crud(): ...
CommanderPrice's user avatar
2 votes
1 answer
2k views

Should I check floating point values in a unit test?

We have unit tests that are running some underlying model. We provide it with some test input, and receive some outputs + floating point scores. What's a good practice from a unit-testing standpoint? ...
de1337ed's user avatar
  • 175
-1 votes
2 answers
1k views

How do you unit test methods with hard/impossible inputs to hardcode?

I have the following problem. I have a method which takes two other custom objects to work. This objects are required by the method because they have the information that the method requires to ...
Jorge Verdeguer Gómez's user avatar
-4 votes
1 answer
1k views

Is it possible to derive a test suite to achieve 100% path coverage? [closed]

Here is an example with the function: Examining this I believe that it is possible to achieve 100% path coverage. My understanding of path coverage is that you need to design test cases such that ...
Sri's user avatar
  • 13
7 votes
2 answers
348 views

Should examples for functions be unit tests?

I'm writing a python function to replace all the non-alphanumeric characters in the keys of this dictionary with underscores. To make sure it's working as expected as I don't have a ton of ...
ADataGMan's user avatar
  • 181
2 votes
1 answer
456 views

Best practices on testing a function based on third party service

I'm trying to figure out how to create unit tests for a function, which behavior is based on a third party service. Suppose a function like this: def sync_check(): delta_secs = 90 now = ...
Manuel Fedele's user avatar
1 vote
1 answer
579 views

How to organize my test functions?

I'm writing a software application of a few thousand lines of code (in Python), and in order to keep the whole thing together, slowly but certainly the need for unit tests (and later, other types of ...
l7ll7's user avatar
  • 263
2 votes
3 answers
335 views

Should I test the debug branch of my code in a unit test?

Lets say I have a function that gets a list of what files to send that are later send over a socket to some other pc. Now usually I keep track of what files have been sent and don't send these files ...
Hakaishin's user avatar
  • 197
1 vote
1 answer
916 views

Is there a cleaner way to test extras_require

I have code reviewed a piece of Python code, but to me it looks really ugly, hacky and complex for something that can be achieved very easily. The code looks something similar to the following: ...
Remco Haszing's user avatar
3 votes
1 answer
2k views

How to keep unit tests independent?

I've read it at many places that unit tests should be independent. In my case I have a class that does data transformation. These steps must be done sequentially, otherwise they don't make sense. For ...
siamii's user avatar
  • 1,320
9 votes
4 answers
7k views

Behavior Driven Development and Unit Testing in Python [closed]

We might be interested in starting to incorporate a unit test suite to our project, which is coded in Python (and it uses Redis, PostgreSQL and some third-party libraries, if that bears into the ...
Juan Carlos Coto's user avatar
1 vote
2 answers
2k views

How to populate a private container for unit test?

I have a class that defines a private (well, __container to be exact since it is python) container. I am using the information within said container as part of the logic of what the class does and ...
Sardathrion - against SE abuse's user avatar

15 30 50 per page