streamparse
streamparse copied to clipboard
How to run Unit tests on Bolt and spout logic?
Hi I would like to be able to write unit tests on my bolt and spout logic instead of using sparce run to "test" the code. Are there any examples of setting up such a unit tests to test the initialize, process and next_tuple logic?
I presume I will need to stub out the emit method and call process on a tup fixture.
along the lines of this: https://github.com/Parsely/streamparse/blob/2.1.x/test/streamparse/test_bolt.py
Is that correct?
So is this the correct way of going about things?
I think it would be helpful if there were some test helpers to make this a bit simpler to do..
I'd also like a more compact and intuitive test harness. This is what I'm about to run with: https://gist.github.com/topiaruss/264015387b69f867c4bf
Update: I've just added a simple test for a spout.
Alternative ideas welcomed. How can we make 100% test coverage quick and easy? What other aspects of storm should the framework make trivial (beyond next command to spout, and a simple tuple to a bolt?)
Update 2016-02-28: Just updated the above Gist. I'm finding the test harness really useful. Debugging during an sparse run is hard, but it works fine in py.test, as I demonstrate, and I can easily set up test scenarios to get 100% test coverage.
@Richard-Mathie, @topiaruss are you running end to end tests? If so how are you going about that?
@topiaruss @amontalenti @kbourgoin @dan-blanchard Time to get serious about this :)
I created a repo with some notes. I'd like to turn it into a py.test plugin eventually. I'm a pytest amateur, and it's not obvious to me how to get started. Input from any of you would be welcome.