Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unit testing aspx views

Is there a proper way yet to unit test views with the aspx view engine?

I've been playing with various ways that will let me get a parseable string as a result like :

view.RenderView(viewContext);

But I'm not having any luck so far.

Most of what I've read strays into integration test territory. Integration test overlap a fair bit but don't allow me to use dummy data to check the output, which is the main thing I'm trying to achieve by unit testing views.

like image 424
flukus Avatar asked Jul 08 '26 10:07

flukus


1 Answers

Have you checked out Selenium? It is directed at Web UI testing and is discussed in Hunt and Thomas' Pragmatic Unit Testing in C# with NUnit. It uses NUnit although it does so in a way that is really more of a system test than a Unit test (simply because you have to bring up the web app and navigate to your page to test it). Sorry that I didn't go down this route in my earlier answer but I was in a bit of a rush yesterday morning!

There is also NUnitAsp but that project has been essentially abandoned. It works and was widely praised in its day but I'm loathe to recommend anything that is no longer under active development.

like image 151
Mark Brittingham Avatar answered Jul 11 '26 02:07

Mark Brittingham