Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

have fun testing a stateful system without order-dependent tests


Can each test be executed separately? Then it's a collection of tests. Otherwise, that's just one test with many steps posing as separate tests.


Set the state to a known state, test, assert the resultant state is what I think it should be.

Also testing a sequence of operations is fine, but that's one test not n of them. This is analogous to integration tests: they test several units but it's a single test.


> Set the state to a known state

how do you guarantee that the state that you set as the initial state is reachable in your system?


With an integration test. It executes multiple operations that are order dependent, but then this is a single test, not multiple.


Wouldn't you be testing state transitions within the context of a single test however? The system having order dependency isn't the same as the tests having order dependency.

In other words, tests shouldn't be coupled together. Reinitialize, and rerun steps, between each test that stands alone.


Maybe unit tests are at the wrong abstraction level to test for state-dependent bugs.


State, not even once.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: