views:

40

answers:

1

I'm aware of things like Selenium and WatiR, but what I'd like to be able to do is to test that the view renders the HTML I expect when it's presented with given inputs. No javascript debugging, just checking the HTML. However, to do that, I need to be able to execute the view programmatically. Is there any reasonable way of doing this? Will it work with non-compiled views?

+1  A: 

NUnit is the wrong tool for the job. The other two you mention would be examples of the right tools. Even if you find a way to use NUnit you'll end up writing (or using) an HTML parser and replicating a lot of the functionality of Selenium et. al.

tvanfosson
Well, I was planning on using the HTML agility pack, which is why I thought it might be interesting to re-address this question.
Julian Birch
If you intend to go down this road, I think you'd have to figure out how to mock the response stream on the HttpContext and catch the text written to it (perhaps with a filter). You could then use the captured string as input the the agility pack. Google for how to set up compression in MVC. That's done using a filter on the output stream and it may give you some ideas. I'd still go with Selenium, et. al., though.
tvanfosson