alfredodeza / pytest.vim

Runs your UnitTests with py.test displaying red/green bars and errors
274 stars 40 forks source link

Easily re-run failed tests #39

Closed bradgrimm closed 8 years ago

bradgrimm commented 8 years ago

Since the plugin already stores out all the failed tests it would be nice to have a new parameter that allows only re-running the failures. Something like: :Pytest failures

alfredodeza commented 8 years ago

Have you seen the looponfail flag? It might accomplish what you are asking:

https://github.com/alfredodeza/pytest.vim#looponfail

bradgrimm commented 8 years ago

@alfredodeza I had seen that option. I was under the impression it was running all the tests again. I have some big files that take a while to run, and I often have a small subset that fail. It is nice to go through and address those tests, and then just rerun that small subset (since it is a big file). Am I misunderstanding loop on fail?

alfredodeza commented 8 years ago

Oh I see what you are saying, you want just the subset. So looponfail would only work for your use case if you are working on a single test not a whole set like say, in a class (unless you don't mind waiting for all of them to pass/fail).

Even though we may know what tests failed I am afraid approaching this is very tricky and not sure if possible. When tests fail, the plugin knows about paths, line numbers, exception name, and traceback. If you are running tests, like in a whole file (:Pytest file) it would be hard to re-run all the ones that failed because the plugin would need to run them one by one.

The plugin can run file, class, method, function, and project, but it does that by calling py.test once. There is currently no way to (in a single call) to run one test from class A, another one from class B, and another one in some function.