"Elise Rattigan" wrote:
> Just a question about unit testing. In the workshop from last week, in the
> __init__.py file, app.config.from_object(Config) was changed to
> app.config.from_object(TestConfig). Does this mean that we need to do that every time
> we decide to run tests and then change it back to Config when we're done? Or we
> should be running the test config as we build and then changing it back when we're
I think that depends on how you develop. If you're doing test driven development, then
probably TestConfig would be the defualt mode. However, alot of people prefer to work
with DevConfig, where you use the the database as a kind of scratchpad: you enter data
and manually inspect etc.
The you switch to Test config before every commit and after every merge, to confirm
> Also, in terms of what to test, for unit testing we should choose one model and run
> unit tests for all the routes. What should we be doing system testing on? Obviously
> in practice, it would be ideal to do everything, but just in the context of this
You typically run unit tests for methods which could be the routes, but can also be
targetted at helper methods in the model.
In practise you should aim for 100% coverage, but as that is time consuming and
repetitive, just aim to cover one nontrivial model (e.g. try to test all model methods
and controller methods related the question class).
To test routes properly you should probably be sending http requests, so system testing
with selenium may be more appropriate.