I have unit tests covering my model binders. I create a ModelBindingContext and populate the ValueProviderDictionary with my test values. I am sure that as soon as my controller receives the model, everything is covered by testing, and everything happens correctly. I am also sure that if the BindingContext is correct, my model will bind correctly. That I do not feel confident that my view, when sent back, will correctly fill the BindingContext.
I started writing WatiN tests that fill out forms, publish them back and check the result. This is normal, but it seems very ... indirect. For example, a page that says "your order has been saved" after clicking the "Submit" button - I will need to go to the database to make sure that it was saved correctly. I already have tests covering this when the model passed to my controller is x, y is stored in the database. Why am I repeating this code in a view test?
I really want to populate the view, click submit, and check either (a) the BindingContext or (b) the model returned from ModelBinder.
Are there any practices regarding how to do this?
Just wanted to add that this will be in addition to the WatiN trials. I have ~ 50 WatiN tests right now (with lots to add), and if I could do the above without WatiN, this will only remove a few tests. I will continue to use WatiN for what it's good for, but I feel like I'm abusing this test for those few tests now.
source
share