For example, if you have ten tests that must be run in a particular order, you can simply turn them into a single gigantic test.
As long as it's all green checkmarks and I don't need to run all the tests every time then it must be ok right?
I'm not talking about sharing state between tests.
I'm talking about the code being tested having global state that is deeply entrenched in how it works, it's unreasonable to refactor, yet a test suite must be written.
What truly sucks is someone not even writing tests at all for the tangled parts which is extremely common to find because it breaks someone's precious mental model and they don't want to put their name on it.
Could you give a specific/actual example of this? Technically a database is global state that is deeply entrenched in how an app works, but its trivial to make order independent tests that require certain records to exist.
I'm not confident enough to say there aren't exceptions here though.
You'll have to explain, then, the significant difference between:
test_one:
lots of setup code for scenario one
assertions
test_two:
lots of setup code for scenario two
assertions
where test_two only runs after test_one;and:
test_one:
lots of setup code for scenario one
assertions
test_two:
lots of setup code for scenario one
lots of setup code for scenario two
assertions
Of course, if the same "setup code for scenario one" running twice breaks things, then so would "running the suite twice", sure.> I'm talking about the code being tested having global state that is deeply entrenched in how it works
"code being tested having global state that is deeply entrenched in how it works" does fall under "sharing state between tests".
If your project language is Python, pytest is providing all kinds of tools to setup and reset all kinds of global state (see the monkeypatch fixture). In other languages this can be solvable obviously, you might just need to write more helpers and might be more careful.
If you don't write your tests independent from each other, you will have an awful time debugging any failure and will waste insane working hours which could be prevented by a little bit of discipline.