Llewellyn Falco and I had a conversation many years ago (June 2010?) about the best way to test Web UI. During that conversation we referred to the two classifications/mechanisms of web testing as front-door and back-door web testing. That is how I still think of the two types many years later, although I recognize that not many people in the industry use those terms.

In front-door web testing you are using the browser to drive the test, which more closely tests what the user sees, but offers limited ability to manipulate or control the data and other dependencies. The other drawback of this type of testing is if the test modifies data, there needs to be some way to get back to a clean slate after the test finishes.

In back-door web testing you call the controller or presenter directly (assumes you are using MVC pattern, or have done a good job separating the Greedy view into a presenter). The advantage of this pattern is that you can control the dependencies and data context under which the test runs more easily by using in memory repositories, mocks, and things of that nature. The main issue with this type of testing is that these controller methods return some sort of model and view name, making it difficult to test what the user sees. Because of this, you can have complete test coverage over the controllers but still have bugs in the view.

In January of 2011 ASP.NET MVC 3 was released which allowed different view engines to be used to render the views into HTML that would be sent back to the client. Because the View engines were easily pluggable and the Razor Engine was packaged separately this allowed back door testing to call the engine to produce HTML. This allowed back-door web testing to get closer to what the user was seeing and eventually resulted in Llewellyn augmenting Approval tests with a mechanism for Approving HTML.

However, there are still problems with this approach. Two of the biggest problems are

  1. changes to the layout template break all tests
  2. inability to test JavaScript manipulations of the page

This blog was cross posted on the Crafting Bytes blog at Web UI Testing Part 1: Front-door and back-door testing

I just finished forming a new company called Crafting Bytes with Brad Cunningham and Ike Ellis. We wanted to start taking on bigger projects using the techniques that have made us so successful as consultants. Over time we have noticed that we do much better with the projects when we take control of the project management as well as the development rather than simply augmenting the development staff. What is different about our project management style than the project management style of other companies that we work with?

One major difference is that we don’t use scrum. In a sprint developers spend a lot of time estimating the work. Estimating can be important when the estimate is used to determine whether or not the work should take place at all. However, in most cases companies were using the estimate to inform management when the product was supposed to ship, so that they could relay that information to the customer. It would be a better idea to relay the information to the customer *after* the work has been completed. It is much more accurate that way. The other reason managers were requiring estimates was to figure out how much work should be completed this sprint. So in other words managers were requiring estimates for the sole purpose of the project management methodology they were using.

The thing is estimates take a lot of time, and they are rarely accurate. Our thought was let’s forget scrum and just go with a simple Kanban board (from the Lean school of thinking). By doing this we can save ourselves countless hours of trying to figure out how much time things are going to take, and spend more time simply doing them.

OK, so that saves a couple days every sprint, but then what is the purpose of having a project manager at all? I admit that the project managers of many companies are totally unnecessary. You know the type, they spend most of their time polling individual people “are you done yet”. They could easily be replaced by voice recognition software that recognizes the word “yes”. This isn’t really project management, it is instead project reaction. Project *management* would be managing the work of the project, prior to it starting. In short a project managers job is to figure out which work is the most important and which work is so unimportant it doesn’t need to be done at all. Great project managers remove all unnecessary tasks, that is all tasks that don’t lead to working software, and prioritize which features are the most important for the business and the user. In short they control the prioritized list.

Thinking of project management as simply controlling the list of things that need to get done and prioritizing the most important simplifies the job of the project manager and helps the team achieve minimum “time to value” – a vastly underrated metric.

This blog was cross posted on the Crafting Bytes blog at Project Management As A Prioritized List

I think this is my 6th year speaking and 7th year attending at SoCalCodeCamp (San Diego edition).  For the past several years I have tried to give an advanced talk and an intro talk.  For the advanced talk I decided to give OData again for several reasons.

  1. Nobody else was speaking on it
  2. I has already signed up to give a webinar on it
  3. I still think it is relevant
  4. It is so flipping cool

The slides and demos for that are in the previous blog post.

When it came time to pick an intro talk I combed the SoCal Code Camp web site looking for gaps.  The gap I found was not what I am used to speaking about.  I was going to have to give a talk about . . . the front end.  (NOOOOO!!! Wait, I mean Sooooo what? What’s the big deal about the front-end?)  Specifically, I wanted to give a talk about using an off-the-shelf CSS framework called Twitter Bootstrap.  I had used it in my job, and in my side project, so I figured that should qualify me :) .  I put in the abstract and then forgot about it.

Months go by, and here it is the week before the talk.  I check back and realize a couple of things

  1. I had not used Twitter Bootstrap since I wrote the abstract
  2. There are over 80 people interested in the talk
  3. My daughter Julia has a soccer tournament on the same weekend

Long story short I wasn’t quite as prepared as I should have been.

The first day was pretty hectic.  First I saw Robin Shahan give a talk on Windows Azure in Real Life.  She good-naturedly accused me of heckling, but I think I was just encouraging audience participation :) .  The second talk I saw was Search engine building with Lucene and Solr, but I left as the speaker transitioned into Solr.  I ran home to help Julia get ready, and then back to Code camp to see Windows Azure Mobile Services by Bret Stateham.  Great talk as always, but I had to leave early to see the soccer game, which they lost 2-3.  I hustled back for NancyFX, which was probably my most influential talk of the weekend, then left again to see the final minutes of a 3-2 victory. Woohoo!!!

That night at the Geek dinner we found out that Woody was passing the baton after 8 years of running the SoCal code camps to Hattan. I also found out that night that my daughters team was playing the Surf at 10:00 (the same time as my OData talk) which sucked.

The second day I suffered through Data Flow Architectures, before giving my OData talk.  While speaking I learned that my daughter’s team lost the 2-2 game in penalty kicks.  The bright side to that was I didn’t need to worry about a conflict that afternoon.  I then went on to see Timothy Strimple on Git and GitHub.  I stayed in the room for Llewellyn and Chris Lucian talking about Agile Metrics, which helped me see some problems with the project that I was on.

The Twitter Bootstrap talk was the final talk of the day.  It was in the TV building, and the room could probably only support 30-40 people, but it was packed.  People were standing along the outside.  Also mildly surprising there were children in the class!  And they asked questions!?!?  And the questions were good!!!

I had no idea how the timing of the talk was going to go, and in fact it ran over, but it was very well received.  I was applauded (some even gave standing ovations – see previous paragraph) and several people stayed behind to congratulate me on a talk that I felt could have definitely gone smoother. I am glad everyone enjoyed it.

Thanks everyone for attending.  Here are the demos and slides. Slides are also on slideshare.

Thanks to everyone that attended the WCF Data Services (OData) webinar.  Here are the WcfDataServicesIntro slides.

I promised I would report on the issue we ran into during one of the demos.  The first issue was Resource not found for the segment ‘Titles’.The reason that I wasn’t hitting it when I tested was because I was querying for a book already in the system.  However, The fix was very simple (after a Google search).  I needed to add:

context.IgnoreResourceNotFoundException = true;

There was one additional error that I encountered, which I did know about but I didn’t hit it until after I fixed the other error.  The enum property that I added was unable to be serialized back across the wire.  The simple fix was just to make those properties internal.  WCF Data Services only cares about public ones.  With that everything ran.

Here are the BooksDataService demos.

I have received some flack for my lack of blog posting. To defend myself let me state that for the past year I have been busy. Really busy. There were many days where I didn’t have time to eat or sleep, much less blog.

After April 12th all that changed. I took a vacation and recharged my batteries a little. Now that I am “not so busy” I have decided to start blogging again. Looking back it wasn’t that I didn’t have interesting things to share, it is just that I didn’t have time to write them up properly. In Word Press and OneNote combined I have over 70 drafts of blog entries. So I am making a public commitment – 10 blog entries a month for the next 3 months to try and catch up.

I have decided to back date any blogs which were started so that they make sense chronologically to me. For example my first entry is going to be about updating the blog to use HTML5 and CSS3. I performed a demo of doing that for the spring quarter UCSD Extension ASP.NET MVC class. So I am going to file it as if I was able to write it up at that time, because that is where I did the research. However some of the entries are really just titles and a couple of bullet points, so those will get new dates.

Here I go…

[Update: Adding Converting Blog to CSS3 on May 3rd]

When I started doing more complicated things with ASP.NET MVC it was using Razor. In some ways that was unfortunate because some of these things were actually a little easier in prior versions. It starts to get complicated when you start composing partial views and multiple javascript files. First some Javascript files depend on other javascript files. And secondly partial views need certain scripts to be included that the main page doesn’t necessarily know about. The problem is that Razor doesn’t really deal with these things very well.

For this blog entry I am going to focus on getting JavaScript files included from partial views. This question has been asked numerous times on Stack Overflow

  • http://stackoverflow.com/questions/863436/is-it-bad-practice-to-return-partial-views-that-contain-javascript
  • http://stackoverflow.com/questions/912755/include-javascript-file-in-partial-views
  • http://stackoverflow.com/questions/4707982/how-to-include-javasscript-from-a-partial-view-in-asp-net-mvc3
  • http://stackoverflow.com/questions/5376102/mvc-partial-views-and-unobtrusive-jquery-javascript
  • http://stackoverflow.com/questions/7556400/injecting-content-into-specific-sections-from-a-partial-view-asp-net-mvc-3-with
  • http://stackoverflow.com/questions/11098198/is-it-ok-to-put-javascript-in-partial-views

In fact, I bet if you put all of the questions in 1 it would have quite a point total. But it is spread into so many slightly different questions that it is tough to quantify.

So first to define the problem. The ideal place for scripts is right before the close of the body tag. The default template’s master/layout view contains a scripts section for this purpose. Unfortunately sections can only be defined, not added to. So that means that the main view is the only one that can place script files in that section. It can get very awkward if there are script files that are very specific to the partial view, especially if the main view includes a number of partials. Basically the master view has to maintain the list of scripts needed by the entire tree of partial views.

Let’s make the problem more concrete. Let’s say I have three main view that include a partial view. That partial view uses another partial view. I change the leaf partial view so that I need some JavaScript. I have to find out where all of the views are that include me (but of course no view includes me directly), and add the script to those views. In short – YUCK.

While researching a solution to the problem, I came across a couple of promising solutions, namely:




The first didn’t take into account paths, and the second was way too complicated in terms of how to use them, so I came up with this nice simple hybrid of the two solutions.

Here is an example of its use
Either at the top of the file or the web config, need to use the namespace

@using PartialsWithScripts.Helpers

To include a script in a partial view simple add it like so:

@{ Html.MyAddScriptFile("~/Scripts/App/contact.js"); }

Here is the code

public static class ScriptHelpers
    const string ScriptContextKey = "ScriptContext";

    public static void AddScript(this HtmlHelper htmlHelper, string path)
        var scriptContext = GetScriptContext(htmlHelper);

    public static IHtmlString RenderScripts(this HtmlHelper htmlHelper)
        var httpContext = htmlHelper.ViewContext.HttpContext;
        var scriptContext = httpContext.Items[ScriptContextKey] as HashSet<string>;
        if (scriptContext != null)
            var builder = new StringBuilder();
            var urlHelper = new UrlHelper(htmlHelper.ViewContext.RequestContext,
            foreach (var scriptFile in scriptContext)
                builder.AppendLine("<script type='text/javascript' src='" 
                    + urlHelper.Content(scriptFile) + "'></script>");
            return new MvcHtmlString(builder.ToString());
        return MvcHtmlString.Empty;

    private static HashSet<string> GetScriptContext(HtmlHelper htmlHelper)
        var httpContext = htmlHelper.ViewContext.HttpContext;
        var scriptContext = httpContext.Items[ScriptContextKey] as HashSet<string>;
        if (scriptContext == null)
            scriptContext = new HashSet<string>();
            htmlHelper.ViewContext.HttpContext.Items[ScriptContextKey] = scriptContext;
        return scriptContext;

…for Data based services

There are two basic problems with using WCF to expose data services and both boil down to producing too many methods
1) You have to create a minimum of 5 methods per type that you want to expose (CRrUD)
This is basically – “I have too many types of things to expose”
2) You have to create a new method every time a client comes up with a different way to query the data
a. Get Orders by Product
b. Get Orders by Customer
c. Get Order By OrderId
d. Get Orders by Category
e. Etc
This is basically “There are too many ways to query my data”

There is one other reason that is sometimes overlooked, which is you have to modify all those methods when you want to do something across the board, like service side paging or filtering out rows based on the current customer. These use cases are difficult to apply in an aspect oriented fashion and often require the modification of many different pieces of code.

While teaching my fall MVC class, I was under a space constraint on both my e-mail and my hard drive. (Since then both have been cleaned out and upgraded). Anyway I was receiving these huge files containing a whole bunch of packages that I already have on my machine, and could easily download again. So I decided to make a video to demonstrate how to use NuGet to fix the problem.

You can watch the video on my YouTube channel

I use WordPress for my blog. I wanted to update the bog to use HTML5 and CSS3. It wasn’t like I was using tables for layout or anything but there were three things that I didn’t really like the look of.

The first thing I wanted to fix was the Web font. I was using JavaScript to produce the font, and it was not giving good results in all browsers. I searched for and found the Whiteboard regular font I was using. Unfortunately not all font files are supported in all of the browsers. To support all browsers you need at least 2 files. I downloaded and copied all of the necessary files (ttf, eot, woff, and svg). Then I edited my main stylesheet and added this to the top

/* @font-face kit by Fonts2u (http://www.fonts2u.com) */ 
	src: url("House_Whiteboard_font_by_callsignKateJones.eot");
	src: url("House_Whiteboard_font_by_callsignKateJones.eot?#iefix") format("embedded-opentype"),
	url("House_Whiteboard_font_by_callsignKateJones.woff") format("woff"),
	url("House_Whiteboard_font_by_callsignKateJones.ttf") format("truetype"),
	url("House_Whiteboard_font_by_callsignKateJones.svg#Whiteboard") format("svg");

I removed the typeface.js scripts and the extraneous styles, and voila, I now had working fonts in all browsers.

The next thing I wanted to focus on was the text on the sticky note. I wanted it to look written on. For this I needed the new CSS3 rotate transform

	/* filter:progid:DXImageTransform.Microsoft.BasicImage(rotation=-0.1); */

The last thing I didn’t like was the whiteboard boarder. It looked alright in Chrome (which was my default browser, but not so good in IE. I tried a couple of things including border gradients and background gradients, but I couldn’t get it to look right. Finally I had to resort to JavaScript which sucks.

I missed the first session because of lack of sleep and the fact that I hadn’t finished my slides for the day’s second talk. I came in at the end of Bret Stateham’s talk on Getting Started on Azure. I didn’t expect anyone to show up for my talk on Azure Tricks and Tips because of the advanced nature of the talk and that not many people are doing Azure yet. I was pleasantly surprised to find 10-15 people there, which was a great number for that kind of talk. The talk was well received and there were lots of good questions. I have uploaded the slides for the talk.

Afterwards I went to lunch with the DM gang. After I came back I was going to check out David Pallmann’s talk but I was about five minutes late, and it was in the same room as mine, so it was hot stuffy and crowded. Instead I ventured over to John Bowen’s talk on the Future of XAML for XAML Developers, which was in a much nicer room. I wanted to be in the same room for the talk after the next one, and Llewellyn assured me that it was going to be crowded, so instead of heading over to several other talks I just hung out in the same room and suffered through Fundamentals of Metro Style Applications. Then it was time for my favorite talk of the day – Michael Palermo’s HTML5 for the Real World. The crazy thing was that it was my favorite talk despite knowing all the material! His dynamic and engaging style was simply fun to listen to. After that was over I headed over to a fairly good talk by Paul Mendoza on Writing Maintainable JavaScript.

The Geek dinner was great – Lllewellyn was congratulated on the schedule, and I met a few people and had some interesting conversations on the CAP theorem and light particles as well as digitizing old film.

I was undecided as to which topic to attend first the next morning. On a whim I decided to attend the Hacking Your Memory session. Much to my surprise that became my favorite session of the entire camp – It Was Awesome! The speaker (Gary Hoffman) did a great job, the slides were well prepared, the topic was interesting and the audience was really engaged. Check out the site if you are interested.

Next I was trying to decide between WordPress Ninja!, and .NET TDD Kickstart. by Barry Stahl whom I had met two nights previously. I made the wrong choice and attended the WordPress Ninja! talk, which should have been renamed WordPress Beginnner!. During lunch Llewellyn talked me into doing the afternoon sessions that was supposed to be with Woody Zuill, but due to family emergencies Woody had to cancel. I begged out of the first one to attend a Node.js talk. I then trekked back over and helped give the talk on Testing EF, ASP.NET and ASP.NET MVC. I stayed in the room to attend the final talk User Driven Development which had some interesting discussion.

Great conference as always. Kudos to Woody Pewitt, Bret Stateham, Llewellyn Falco, and the rest of the volunteers for their efforts.