[Kristoffer Bakkejord, Test Podcast] To be clear Zeebe isn't "untestable", but it requires a different approach than say unit tests, and figuring that out isn't necessarily easy. Just because it's not, doesn't mean it's a bad design decision.
Here's one test implementation for Zeebe BPMNs (i.e. DAGs): https://github.com/zeebe-io/bpmn-spec (this doesn't cover our use case, which is why I'm looking into an approach in pytest).
[Chris NeJame, Test Podcast] In my opinion, any design-related decision that makes testing things in an atomic way less achievable, is a bad design decision, as this inherently introduces large amounts of technical debt (i.e. time was borrowed from the future for a perceived speedup in the short term, and this will likely cost more time in the long term than what was perceived to be saved in the short term).
In this case, in order to pay down the technical debt completely, you would have to go bankrupt and rebuild everything (unless you can piecemeal separate out individual components to be handled by separate, atomically testable components).
I understand that your system would still be testable. But what I'm saying is that in having to involve so much in every one of your tests, and having to have so many more, they will take a much longer time to run and to write than they would if you could test things atomically, and you will likely spend much more time maintaining them.
Consciously sacrificing testability, for the sake of short term speed ups, is by no means uncommon, because testing is often seen as secondary and not as important as writing the "actual" code. But I have never heard of a case where doing so didn't bite the person in the ass, and every system I've worked on that focused only on operating at the DAG level (which is surprisingly not 0) was a buggy, unmaintainable mess once it was down the road enough to be considered (by some, but not me) to be MVP.
[Kristoffer Bakkejord, Test Podcast] > any design-related decision that makes testing things in an atomic way less achievable, is a bad design decision
Agreed.
I understand that your system would still be testable. But what I'm saying is that in having to involve so much in every one of your tests, and having to have so many more, they will take a much longer time to run and to write than they would if you could test things atomically, and you will likely spend much more time maintaining them.
It doesn't seem we're on the same page here. I do find Zeebe to be quite testable. With very little knowledge of pytest plugins and not too much time, I managed to create a basic framework that allowed me to test Zeebe BPMNs. Wanting to iterate on this, I met some challenges with how pytest works. But that don't mean either pytest or Zeebe is a bad design decision – just that my assumptions about it was wrong (and I can learn from this).
Consciously sacrificing testability
I don't think I am doing that,...
that focused only on operating at the DAG level
Not sure I'm following you here. You may have had a bad experience with DAG systems, but I don't think you should have assumptions about every use case and implementation considerations others may have.
Anyways - I appreciate the discussion. You come with many good points. I was looking for some input on how to use pytest with test classes, and I've come to a conclusion that this isn't the right path.
[Chris NeJame, Test Podcast] The problems with such a system likely aren't obvious now, and may not be for a time, but, like I said, taking up technical debt is about short term gains, with long term consequences. The problems will become more apparent as you build out the application. As more complexity is introduced, it will exponentially grow out of control.
The systems I worked with all had in common an inability to test individual steps in isolation. This meant that the automated tests had to operate at the end-to-end level, which made them very expensive and time consuming to run, and would break regularly, especially when third party dependencies were having issues. They would also prevent developers from finding out the full picture in regards to what was broken, because if an earlier common step was broken, everything that depended on it could not be tested.
The end result, was a lot of wasted work, and very slow developer feedback loops, which wasted a lot of time.
I wish you the best of luck though. I'm sure this will be quite an informative/educational experience in many ways :)
def ensure_some_default_settings() -> bool:
...
return # ... True or False
if ensure_some_default_settings:
did you mean `if ensure\_some\_default\_settings\(\):`
my_project.connections.redis_client
,i.e. you need to patch it from the POV of the file you are using. if there are cross reference like that (with multiple layer of referencing) it become harder. since patch only replace the "reference", and reference which is different in multiple files, won't be replaced.
capsys.readouterr()
but no success ^^
assert expected in captured.out
would work?
[a4z, Test Podcast] I wonder if I could get some startup help here, please!
I decided to share my helper scripts with colleagues, and the best option might be to distribute them as pip.
So I create some pip, say, mytool
Of course I know that mytool scripts work ( =@ ), but just to be sure, I would like to add some tests.
So I have this pip project layout
- mytool
- tests
LICENSE
setup.py
... (rest of pip files)
now what to do that file in tests can import mytool
and optimal, that even VS Code knows about mytool when editing the test file
(You might notice on my question, python is not my dayjob)
[Erich Zimmerman, Test Podcast] General question -- in past testing, I have made use of delayed timing on assertions. For example, I may send an event to a system, but the assertion based on the event isn't immediate.
```some_object = MyClass()
related_object = NextClass(some_object)
some_object.take_action('action')
assert related_object.updated_property == 'action'```
In Nunit and others, there is support for basically a polling assertion, where you check the predicate until a timeout is reached.
Pytest and the Python assertions don't support this directly (well, as far as I can tell), but I don't even find any conversations online about doing something like this.
So, I'm wondering if this approach doesn't "fit" in the Pytest approach to testing?
I wrote a simple function on my own, called wait_for_assert
that takes a predicate function, resulting in an AssertException if the predicate is still failing after some time, so I'm good with that on the "works for me" paradigm. But I'm just curious if Pytest thinking would point me down a different road.
[David Kotschessa, Test Podcast] Thank you @brian for an episode back in 2019 "From python script to maintainable package."
I created my very first pip installable package, which is a community provider for faker to create airport data. It's a tiny thing, but it was a great lesson in documentation, setting up tests, packaging, etc.
https://pypi.org/project/faker_airtravel/
flit
was definitely the way to go too
[Tony Cappellini, Test Podcast] How do you deal with python3’s end= in the print() function, when using the python logger?
print(‘Python Rocks’, end=‘’)
print(‘Python Rocks’)
How can I make the logger replace both of the above prints?
I”m adding the logger to a program where many of the print() calls use end=
From the logger documentation, I don’t see anything like end= for the logger
[Adam Parkin, Test Podcast] So I want to run coverage.py
on my work project, but here’s a wrinkle: most of our tests are integration tests, so they spin up a set of Docker containers (like each REST API is in a separate running container), and then the tests make HTTP calls to the various services and assert on results.
That’s going to mean that coverage won’t see what parts of the services get exercised by tests doesn’t it? Like if I have a test that looks like:
`\
def test_thing():
result = requests.get('http://localhost:1234/some/path/on/a/container')
assert something\_about\_the\_result```
Since coverage.py\
is running in the container where that test is running and not where the web server is running, all it sees is that the test made a http call to some endpoint somewhere, right? Like there’s no way to tell coverage “oh wait, http://localhost:1234/some/path/on/a/container is actually part of our project, so figure out what code in another container is running and do coverage over that” or is there? Anyone have any experience or ideas on how to get coverage information in this situation?