Doing Tests and Unit Tests of AspForm Web Applications: Setup

This is the beginning of a series of post dealing with AspForm unit tests.

We have two options for running Unit Tests. Both have advantages and disadvantages.

Running Unit Tests Against your local development Box

A test would be written as shown below



This will produce a result such as


To have the test work we MUST configure IIS to provide the appropriate site, for example on 666


Check list:
  • Physical Path is pointing to the image you wish to test
  • IIS port and path are matching
  • IIS Server is running

Running Unit Tests Against a Development Server

Note: You need to STOP the above server for the following to work.
Our test is now written as:


The AspNetDevelopmentServerHost must be pointing at the source folder you wish to test.
We must now change the Web Application project to be found and available:


Again the test will run (with ability to debug into the web application if needed)

Gotcha of this approach

The Web.Config is rewritten at the start and at the end of running unit tests. Occasionally you will get error messages about web.config being locked by another process.

Recommended Approach

The following template is recommended:


That is
        [TestMethod]
        [HostType("ASP.NET")]
        [UrlToTest("http://localhost:666/default.aspx?unittest=devadmin@avalara.com?Unittestlogin=devadmin@avalara.com")]
       // [AspNetDevelopmentServerHost("C:\\GitHub\\develop\\AdminConsole", "/")]
This has the following advantages:
  • If you have multiple branches, then by just changing the IIS settings to point at each branch, you can run the tests against each branch without touching the files.
  • If there is a team working on the project, then there is no dependency on the physical location of the files (a big plus!)
  • If there is a problem that needs investigation,
    • Turn off IIS
    • Uncomment the AspNetDevelopmentServerHost line and adjust the path (if needed)

Comments

Popular posts from this blog

Yet once more into the breech (of altered programming logic)

Simple WP7 Mango App for Background Tasks, Toast, and Tiles: Code Explanation

How to convert SVG data to a Png Image file Using InkScape