質問

ApprovalTests looks great for legacy code, but the problem is my legacy code runs in an appserver and redeploying the app takes > 2 minutes. Because of this, I'm concerned the feedback loop of running the approval test would make me not want to run it very often. I'd probably end up changing more code without testing as often and probably get into a repeating pattern of "change->test->fail->revert".

Can anyone give me advice on how to use ApprovalTests with legacy code that takes a long time to deploy? Is this exactly what I should expect to deal with or am I writing this test in the wrong way?

役に立ちましたか?

解決 2

I got an answer from the creator of the product:

So the concern you have is "change->test->fail->revert" and this happens, but with smaller and more careful changes you should be able to make good progress, and failing shouldn't be rule, but an exception. Also, remember that in legacy the motto is better, not good. use this test until you refactor enough to get a test that doesn't require an appserver. then you move faster. approvaltests in and of themselves do not need to be big or slow, it is only verification. it's the doing of the test that is big or slow, and while approvaltests work great for that, it by no means a suggestion or recommendation that those are the kinds of tests you want.

Then I asked:

Are you saying, "approvaltests lets you test this way, but that's not a good way to use approvaltests"? If I've interpreted that correctly, what would be a better approach?

And he replied:

yes. approvaltests let you test this way. it's not a good way to unit test. it is most likely the best way to unit test you currently have. use it until you refactor to a better way to unit test (one that doesn't require a server)

Hope this helps someone else with the same question.

他のヒント

What in your project are you trying to test?

If you want to test Forms with Approval Tests you should figure out a way to separate the dependencies from the application and allow the tests to run only against code. The best approach to this is to begin re-factoring smaller chunks of code into unit testable chunks, then the path to separating the display from the data source and dependencies will reveal itself.

This video is good for Legacy Refactoring: http://www.youtube.com/watch?v=aWiwDdx_rdo (Watch the whole thing its worth it)

This video shows a good way to separate the loading of data out from a project: http://www.youtube.com/watch?v=5gIeJ6z82Pk

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top