0

Am working on coded UI tests for my web application. Was trying to isolate repository method calls the same way I'm doing in unit and integration tests, i.e. using Microsoft.Fakes framework. But it seems for the UI tests Fakes are not working, because real method is still called instead of a shim. Without isolation UI test results in affecting the database (for example adding a new user when testing the registration process) which makes it not to be reusable. So was wondering whether it is possible to fake/mock those methods and avoid setting up test database and test web site each time I need to run those coded UI tests.

Didn't find much useful information related to this issue, so will be grateful for any help.

In case of a need here is a link to a very simple example: https://www.dropbox.com/s/m6les7pmto14njq/TestCodedUITest.zip That is a VS 2012 solution with one class library (containing a class with method which simply throws an exception), one web application (containing a page with one button on it which calls mentioned method) and finally one coded UI test which contains the shim of that method and simply opens IE, navigates to the page and clicks the button.

Michael D.
  • 11
  • 2

1 Answers1

0

Coded UI generally tests the real application or the real website. Coded UI is quite different to unit testing in that it does not modify the application or web site in any way. To perform the testing you want I think you need a special web site for testing or a testing mode on the real web site.

AdrianHHH
  • 13,492
  • 16
  • 50
  • 87
  • Thanks for the answer. Yeah, test database and website is also an option, but that will require some manual work before each test run - maintain the test website, recreate the test database. Another option would be to pass a parameter to a page indicating that is a test mode and then refactor the code-behind to handle that situation and isolate appropriate method calls. But that would cause a lot of changes in the code and besides doesn't look like a proper solution anyway. – Michael D. Aug 01 '13 at 14:46