I've tried NUnitASP to test ASP.NET web pages in TargetProcess project. As usual, there are some problems with tool adoption. All these issues have been resolved, but I am not satisfied with solutions and stop using NUnitASP for now. I want to find a better way.
Tests Independence & Database State
To keep tests independent, web application should be in known initial state before every test
The TargetProcess system uses database, so the database should be in the same state before each test. I can't find a better way than executing bat file from command line in [SetUp] method. The bat file contains something like this:
osql -U sa -P -d dbname -i D:\TargetProcess\src\Tp.Model\Sql\testData.sql
This works. Not as fast as I want, but I can wait a minute or two. When database become bigger, this solution might be unacteptable.
Dynamic Controls Insertion and NUnitASP
Most of the server controls inserted dynamically on run-time in TargetProcess. This cause additional problems, since controls ids may change. For example, new TargetProcess' module will insert additional control on dashboard. And I should update many already defined Ids in tests. Here is code sample:
In code control = new UserControlTester("_ctl4", CurrentWebForm) real base control id is "_ctl4". But when add new control on the top of this, its id will be "_ctl5". This is a major issue for now.