I have great difficulty in broaching the subject of testing. We all know the benefits of Test Driven Development (TDD). I believe also that a lot of us pay lip service to it in that we usually implement "our own version" of testing. It's kinda like "a la carte" religion these days whereby "I have a spiritual side" becomes a euphemism for being a "lapsed catholic". Most of us are guilty, the rest are liars.

I have a very caveman-like approach to testing: When I'm writing code for even the simplest Web application, I don't trust a single line of code I write. I will never move from one block of code to the next without checking my presumptions about values held in the previous block. When you work in a RAD environment, you have to constantly make intelligent decisions about such issues as you bring the code forward. As for creating a test plan in advance, get real! Software is written by developers working in real-world environments, under real-world pressures. If you are going to come up with a realistic software quality/testing methodology, then you have to develop a methodology which relates to the way people have to work. If you think I'm being insane then just check out the reaction to the recent comment by no less than Joel Spolsky that "Quality just doesn’t matter that much.”

Lightweight Test Automation Framework

This new testing framework for ASP.NET from Microsoft is a welcome step in the right direction. By "welcome", I mean that we need this, and more. There are tools like NUnit out there already but it behooves the creators of the framework to come up with the best testing tool for that framework - although not written by the same people! Did you ever wonder why they didn't create the test plans and tools in advance? If they had tested first before bringing the recent versions of ASP.NET to market, we'd all be back to writing Java by now. This tool was developed by the ASP.NET QA team to implement regression testing. Maybe now we might be able to apply CSS to all the OOTB controls?

The sample download is based on a Website template - so much for offering continuing support for the Web Application project template. I downloaded the samples and attempted to test an existing ASP.NET application targetted at .NET 3.5 by following the instructions provided. I added the reference to the Microsoft.Web.Testing.Light.dll. If you try to copy the two test pages into a folder using VS Solution Explorer, you will get the following error:

"The source files for this operation cannot be found in this solution"

Instead, copy them into a folder in the project you are testing using Windows Explorer, and then use "Add Existing Item" in the VS Solution Explorer window to include them in the project to be tested.

I decorated my class with [WebTestClass] and my method with [WebTestTag("test")] but had difficulty running the test when following the instructions provided. Eventually, I got it to "run" by using the following URL:

http://localhost/myproject/test/Default.aspx?run=true

When I say I got it to "run", I got the following results:

Lightweight Test Automation Framework

I also got a JavaScript "Sys.WebForms.PageRequestManagerServerExceptionError" warning when attempting to include a write to the log.

I didn't have any more time to fire at this and I would be very interested in getting feedback from others using this tool to test Web Application Projects; definitely fodder for another blog post.

Like most projects on the CodePlex site, proper documentation is non-existent. When the project in question comes from Microsoft, I expect better. At the very least, specify the requirements on the home page such as framework version and if it is aimed at Website or Web Application projects, or both. Please don't make me dig for some passing hint to this information in the little documentation that was provided. And if you run into problems don't even think of using the CodePlex search engine, unless you're planning a vacation while waiting for the results to come back.

Tags:

ASP.NET | Testing



Google Search == Internet Search

by admin 9. February 2009 10:56

I noticed a very interesting article from Jeff Atwood concerning the current state of play with respect to search engines. He makes the point that there really is no competition today when it comes to search engines; Google rules the roost.

Although I feel as Jeff does, that Google has truly earned its position, such a "monopoly" is surely a cause for concern? So, I decided to look a little closer at the statistics for the search engines driving traffic to this blog. Here are the results over a random time period:

VSeWSS 1.3

 

From the stats, it seems I am getting 32X times the traffic from Google as from the nearest competing search engine. It would seem that I better speak nicely of Google? If this was Microsoft's search engine, the wooly hat brigade would be screaming it from the rafters... hypocrisy is alive and well ;-)

Tags:

SEO




You may find following snippet very handy in situations where you want to incorporate a base page in a project that uses a master page. From an architectural point of view, implementing a base page is something you should always consider. If you need to implement something in your content pages at a later stage, you only need to do it once, in your base page class. Personally I use it to add meta content and description tags to each content page in my "Web Application Project" site - think SEO!

Refer to Jim Azar's great article for the base page code for adding the meta tags. Note also that you can add your own tags to the the Page attribute of your base class.

In the Page tag of your content page, pay particular attention to the use of the CodeFileBaseClass attribute as this is used to access the public properties of your base page class. This, along with the CodeFile tag, are the new additions to the Page tag for this particular scenario - if you were not using a base page, you wouldn't have these two attributes; instead, you would just have the usual CodeBehind tag.

Master Page:

<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MyProject.master.cs"
    Inherits="MyProject.MasterPages.MyProject" %>

<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">   
</asp:ContentPlaceHolder>

 

Base Page:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPages/MyProject.Master"
    AutoEventWireup="true" CodeBehind="BasePage.aspx.cs"
        Inherits="MyProject.BasePage" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
    runat="server">
</asp:Content>

 

Content Page:

<%@ Page Title="MyProject - Home" Language="C#"
    MasterPageFile="~/MasterPages/MyProject.Master" AutoEventWireup="true"
        CodeFileBaseClass="MyProject.BasePage" CodeFile="Default.aspx.cs"
            Inherits="MyProject.Default"
                Meta_Description="Code Snippet: Master Page and Base Page"
                    Meta_Keywords="master, base, content" Theme="Style" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
   runat="server">
</asp:Content>