Post by s***@gmail.comwhat is the best practice to unit test an ASP.NET page (aspx)?
It depends on what you intend to test.
If you want to test the back end functionality (data processing) the
test framework of Visual Studio should be sufficient. Just write test
classes and test the member functions that do the job.
Only the setup of test cases with database back end needs special care.
But this is not related to ASP.NET.
The better the GUI is separated from your model the better you can test
the model. Unfortunately this does not go without saying in ASP.NET.
However, if you want to test the interaction with the ASP.NET controls
as well, things get complicated. You may work with mock controls to some
degree.
And if you want to test the client side code as well, thing become even
more complicated. Generic web application test tools might fit your
needs. But usually they rely on stable control IDs, which is not
guaranteed by ASP.NET in general.
Moving on to ASP.NET MVC will improve testability. But, of course, it is
like writing the entire GUI anew - so usually not an option.
Marcel