in

But it works on my PC!

The random thoughts of Richard Fennell on technology and software development

This Blog

Syndication

April 2009 - Posts

  • My NxtGen tour in August

    I will be speaking on developer testing of SharePoint projects using Typemock at both the Birmingham and Manchester NXtGen user groups in August.

    For more details check the NxtGen site.

  • Licensing exception with Ivonna the Typemock add-in (and any other add-ins I suspect)

    Like a good developer I have been trying to run Visual Studio with least privilege; with Windows 7 this seems to work well. My main account is not an administrator, but Windows prompts me for elevated rights when needed. I have been developing happily with Visual Studio and Typemock without any need for extra rights.

    However, when I have been doing some testing using Ivonna, the Typemock add-in, I hit a problem. When I tried to create an Ivonna.Framework.TestSession() I got a Licensing.LicenseException: This copy has expired. Which it hadn’t as I have a fully licensed product.

    I had got so use to not needing elevated privilege I did not consider it to be the problem; so I contacted Sm-Art and Typemock support. The answer was simply to run Visual Studio with administrator privileges (right click on the short cut). Once this is done the licensing exception goes away as Typemock has enough rights to look in the right bit of the registry to access the add-in license. I have suggested that if possible this requirement needs to be addressed.

    The other alternative is to grant your non administrator account more rights in the registry. On a 64bit development box it seems you need to a Read-Write access to HKEY_LOCAL_MACHINE\SOFTWARE\TypeMock and HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TypeMock

  • System.Web.Abstractions missing on a ASP.NET web site

    I recently re-enabled feature on a ASP.NET site. This feature (a set of pages) had been running OK about six months ago for an initial pilot project but was disabled until now until a decision was made to develop the feature fully. In intervening time the web site had other modification and had been rebuilt (it was targeted at .NET 3.5) without issue.

    When I re-enabled the feature (renamed a .ASPX file) I got the error

    Could not load file or assembly 'System.Web.Abstractions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

    Now this surprised me, I had not change the .NET version targeting or changed development environment. In the end I fixed it by copying up the missing DLL to the bin directory. I had tried adding the following to the web.config to no effect

    <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
       <dependentAssembly>
        <assemblyIdentity name="System.Web.Abstractions" publicKeyToken="31BF3856AD364E35"/>
        <bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="0.0.0.0"/>
       </dependentAssembly>
      </assemblyBinding>
    </runtime>
    </configuration>

    On think a bit more I think the issue must have been caused by:

    • I may have upgraded to .NET to 3.5. SP1 in the time frame (but I thought I did it earlier)
    • I have installed MVC on my development PC, and most other posts that mention this issue also mention MVC, usually beta versions.

    EIther way it is fixed now

  • Follow up to my session yesterday at VBug Newcatsle on DataDude GDR

    Thanks to everyone who attended my session at VBug Newcastle last night, hope you enjoyed.

    As I mentioned in my session, to celebrate my talking at VBug, Microsoft chose to release the Visual Studio Team System 2008 Database Edition GDR R2 yesterday. If you are using DataDude you do need to get this installed, it addresses many know issues.

    Slides virtually identical to yesterdays, as used at SQLBits, are on the Black Marble site

  • Speaking in Newcastle tomorrow

    If you are in Newcastle on the evening of the 22nd I will be speaking at Vbug on Visual Studio 2008 Database Edition.

    Hope to see you there.

  • Next Agile Yorkshire Meeting – Exploratory Testing

    Next months Agile Yorkshire meeting is on the 13th May where Ralph Williams will be talking about Exploratory Testing, the session outline sound interesting.

  • Alt.Net ‘In the north’ – wrapping it all up

    Thanks to everyone who was able to attend the Alt.net ‘In the North’ conference today; and also to our sponsors. The event could not happened without you all.

    As promised here is the list of blogs, books etc. we had on the whiteboard.

    Books
    Bridging the Communication Gap: Specification by Example and Agile Acceptance Testing Gojko Adzic
    User Stories Applied: For Agile Software Development (Addison Wesley Signature Series) by Mike Cohn
    Agile Estimating and Planning by Mike Cohn
    Crystal Clear: A Human-Powered Methodology for Small Teams by Alistair Cockburn
    Domain-driven Design: Tackling Complexity in the Heart of Software by Eric Evans
    Sketching User Experiences: Getting the Design Right and the Right Design by Bill Buxton

    Blogs
    http://weblogs.asp.net/scottgu/ (Scott Guthrie)
    http://www.hanselman.com/blog/ (Scott Hanselman)
    http://ayende.com/ (Oren Eini)
    http://mattberseth.com/ (Matt Berseth)
    http://oakleafblog.blogspot.com/ (Roger Jennings)

    Events 
    http://openspacecode.com/contact – Coding events in London, next one 30th May
    http://www.developerdayscotland.com/ - Free community conference in Glasgow 2nd May
    http://www.agileyorkshire.org/ - Agile Yorkshire user group meets in Leeds every 2nd Wednesday in month
    http://www.blackmarble.co.uk/events - Various free events in Leeds/Bradford area

    Tools
    http://www.hanselman.com/blog/ScottHanselmans2007UltimateDeveloperAndPowerUsersToolListForWindows.aspx - Tool list
    http://www.balsamiq.com/products/mockups/desktop - UI Sketch tool
    www.openquarters.org (coming soon) the MVC CMS that Anthony demonstrated at the conference
    and a digital camera to capture your whiteboard drawings

    I think that is all, thanks again to you all for making it such an rewarding event.

    Technorati Tags:
  • Alt.net ‘In the North’ starts tonight

    Looking forward to seeing everyone at Alt.Net ‘in the North’ over the next two days.

    If you cannot make the planning session tonight, but are in Bradford later, we will be in the Titus Salt Pub for a few drinks sponsored by SEED software. We will probably be upstairs from about 8:30pm

    Technorati Tags:
  • Team Build, Code Coverage and MVC

    I have been working on some automated build and testing for a project based on the Microsoft MVC framework. The build was working fine, and test were being run, but I was not seeing any code coverage data in the build summary in Visual Studio for the builds done by the Team Build box. However if I ran the test suite locally on a development PC the coverage data was there. Looking on the Team Build drop location I could find the data.coverage file in the TestResults\<guid>\In\<build user> folder, but it was 84Kb in size, which I learnt means ‘contains no data’.

    After a good deal of hunting I found a pointer to the answer the OZTFS forum. The problem is that as the MVC project is a web project, and it build a _PublishedWebsites folder and puts the assemblies into this. In effect the code coverage is just looking in the wrong place.

    The fix is as follows:

    • Make sure you have suitable TestRunConfig1.testrunconfig file in your solution
    • Open this file in the VS IDE and make sure code coverage is enabled for the assemblies you want (and if your assemblies are signed that the re-sign key is set)
    • Open you tfsbuild.proj file for the automated team build and make sure you have a testing block similar to the block below, change the path to the RunConfigFile as required.

    <!--  
    TESTING Set this flag to enable/disable running tests as a post-compilation build step.
    -->
    <RunTest>true</RunTest>
    <!--
    CODE ANALYSIS Set this property to enable/disable running code analysis. Valid values for this property are
    Default, Always and Never.
    Default - Perform code analysis as per the individual project settings
    Always - Always perform code analysis irrespective of project settings
    Never - Never perform code analysis irrespective of project settings
    -->
    <RunCodeAnalysis>Default</RunCodeAnalysis>

    <!--
    CODE COVERAGE Set the test run configuration
    -->
    <RunConfigFile>$(SolutionRoot)\MyWebSolution\TestRunConfig1.testrunconfig</RunConfigFile>

    • If you test this locally you should get code coverage results, but if you run the build on a Team Build box the code coverage section in the test report will show "No coverage result"
    • Now the important bit – open the TestRunConfig1.testrunconfig file in Notepad and add an extra block to the <regular> code coverage section to additionally point to the assembly(s) in the _PublishedWebsites structure (you could also use the VS IDE on the build box to add the file if you wanted, but this will warn over an assembly being added twice). When complete the XML file should look similar to the one below
    <?xml version="1.0" encoding="UTF-8"?>
    <TestRunConfiguration name="TestRunConfig1" id="b6360bec-8278-4773-a931-f22bfab2c57f" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2006">
    <Description>This is a default test run configuration for a local test run.</Description>
    <CodeCoverage enabled="true" keyFile="MyWebsite\ProjectKey.snk">
    <AspNet>
    <AspNetCodeCoverageItem id="88655819-3261-43ac-b2d8-2d3aa1aabaef" name="MyWebsite" applicationRoot="/" url="http://localhost:0/" />
    </AspNet>
    <Regular>
    <CodeCoverageItem binaryFile="C:\builds\MyWebsite\CIBuild\Binaries\Release\_PublishedWebsites\MyWebsite\bin\MyWebsite.dll" pdbFile="C:\builds\MyWebsite\CIBuild\Binaries\Release\_PublishedWebsites\MyWebsite\bin\MyWebsite.pdb" instrumentInPlace="true" />
    </Regular>
    </CodeCoverage>
    <TestTypeSpecific>
    <WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
    <Browser name="Internet Explorer 7.0">
    <Headers>
    <Header name="User-Agent" value="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" />
    <Header name="Accept" value="*/*" />
    <Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
    <Header name="Accept-Encoding" value="GZIP" />
    </Headers>
    </Browser>
    <Network Name="LAN" BandwidthInKbps="0" />
    </WebTestRunConfiguration>
    </TestTypeSpecific>
    </TestRunConfiguration>

    • Once this is done you can run the tests locally or on the build machine and in both cases MSTest manages to find the assembly to test the code coverage on and reports the results.
    Posted Apr 15 2009, 06:12 PM by Richard with 23 comment(s)
    Filed under: ,
  • Holiday is when you catch up…..

    I got round to listening to the latest Radio TFS podcast today whist out for a run, Adopting Team System with Steve Borg. If you are looking at adopting TFS or even just critically looking at your development life cycle with a view to improving (irrespective of the tools you use), then this podcast is well worth the time to listen to. It actually covers a lot of the points I was discussing at the Agile Yorkshire user group this week in my session of Crystal Clear. By now I would usually have put my slide stack up for all to download, but in this case, as my session was a book review in essence I would like you to read the original Crystal Clear by Alistair Cockburn.

    In my opinion, the key point they both raise is the that it is important to have a process that provides:

    • Safety – provides a framework that means the project can safely be delivered
    • Efficiency – development should be in an efficient manner
    • Habitable – that the team can live with the process (if they can’t the process will be avoided/subverted)

    Or to put it another way (and quoting here from the Crystal Clear book) “a little methodology does a lot of good, after that weight is costly”

    A point raised at the user group in the chat after my session was that of how to get senior people (such as CEO, CFO etc) to buy into the ‘new’ development process (a critical factor for success). Too often it is heard “I don’t care if you are agile or not, I just want it delivered” and no support is provided beyond the actual coding team from the business. A good discussion of this type of problem is in Gojko Adzic’s book Bridging the Communication Gap: Specification by Example and Agile Acceptance Testing. This is written for non software developers and discusses how to make sure that the whole business is involved in the development process, thus enabling the project to deliver what the business really needs not what people think they need. I would say this book is an essential for anyone involved in the software specifications process – and that should be everyone in an agile project!

  • Testing SharePoint Workflows using TypeMock Isolator (Part 3)

    Updated 12 June 2009 - I have been having problems using this technique of Typemock with Sharepoint Workflows, the workflows keep unexpectedly idling as opposed to activating. If you suffer similar problem please check for later posts as to any solutions I find. 

    Now I can test a basic workflow it soon becomes obvious that you could end up with many tests for a single workflow, as a workflow can have any number of criteria that could cause branching to occur. Maybe a sensible way to write the tests is using Fit/Fitness to provide the test cases in tabular form?

    So to this end I have added a bit more code to my Typemock/Sharepoint test project (after installing the Fit libraries as detailed in my previous posts). I now have a single test that loads a set of test criteria from an HTML file (my previous posts discuss why I am using HTML files as opposed to the Fit Wiki).

       1: [TestMethod]
       2:      public void WorkFlow1SwitchOnTitle_DataViaFitnesse_Success()
       3:      {
       4:          fit.Runner.FolderRunner runner = new fit.Runner.FolderRunner(new fit.Runner.ConsoleReporter());
       5:          var errorCount = runner.Run(new string[] {
       6:                  "-i",@"WorkflowTestCases.htm", // the htm file that holds the test
       7:                  "-a",@"TestProject.dll",  //we have the fit facade in this assembly
       8:                  "-o",@"results"}); // the directory the results are dumped into as HTML
       9:          // fit can fail silently giving no failures as no test are run, so check for exceptions
      10:          Assert.AreEqual(false, Regex.IsMatch(runner.Results, "^0.+?0.+?0.+?0.+?$"), "No tests appear to have been run");
      11:          // look for expected errors
      12:          Assert.AreEqual(0, errorCount, runner.Results);
      13:          
      14:      }

    I then have an HTML file that contains the test cases (remember to make sure that this file is deployed to the output directory)

    import
    TestProject
    Workflow Fit Tests
    Upload Document With Title Document Approved?
    ABC True
    XYZ False
    abc True

     

       1: <HTML><HEAD>
       2:     <body>
       3: <table border="1" cellspacing="0">
       4: <tr><td>import</td>
       5: </tr>
       6: <tr><td>TestProject</td>
       7: </tr>
       8: </table>
       9:     
      10: <table border="1" cellspacing="0">
      11: <tr><td colspan="2">Workflow Fit Tests</td>
      12: </tr>
      13: <tr><td>Upload Document With Title </td>
      14: <td>Document Approved?</td>
      15: </tr>
      16: <tr><td>ABC</td>
      17: <td>True</td>
      18: </tr>
      19: <tr><td>XYZ</td>
      20: <td>False</td>
      21: </tr>
      22: <tr><td>abc</td>
      23: <td>True</td>
      24: </tr>
      25: </table>
      26:  
      27:     </body>
      28: </html>

     

    Finally we need to create the facade class that wrapper the workflow function for Fit to call. In this sample I just popped the class in the test project for simplicity. Notice it is this facade class that contains all the Typemock bits, also that I make use of the helper class I created in my previous post to actually run the workflow.

       1: using System;
       2: using TypeMock.ArrangeActAssert;
       3: using Microsoft.SharePoint.Workflow;
       4:  
       5: namespace TestProject
       6: {
       7:     public class WorkflowFitTests : fit.ColumnFixture
       8:     {
       9:         public string UploadDocumentWithTitle;
      10:  
      11:         public bool DocumentApproved()
      12:         {
      13:  
      14:             var fakeProperties = Isolate.Fake.Instance<SPWorkflowActivationProperties>();
      15:             var fakeItem = fakeProperties.Item;
      16:             Isolate.WhenCalled(() => fakeItem.Title).WillReturn(this.UploadDocumentWithTitle);
      17:  
      18:             // Act
      19:             TypemockWorkflowTests.WorkflowRunner(typeof(SharePointWorkflow.Workflow1), fakeProperties);
      20:  
      21:             // Assert, if a document is approved must call the following two line
      22:             try
      23:             {
      24:                 Isolate.Verify.WasCalledWithExactArguments(() => fakeItem.Update());
      25:                 Isolate.Verify.WasCalledWithExactArguments(() => fakeItem["Approved"] = "True");
      26:                 return true; // we called all the updates expected
      27:             }
      28:             catch (TypeMock.VerifyException)
      29:             {
      30:                 // it did not call something expected, check if it was just the not approved path
      31:                 Isolate.Verify.WasNotCalled(() => fakeItem.Update());
      32:                 return false;
      33:             }
      34:  
      35:         }
      36:     }
      37: }

    I am currently working on a sample of this testing technique, that does a bit more than a simple branch on if test, I will post a set of sample code when I am done.

  • Visual Studio 2008 DBPRO GDR QFE (wow loads of TLAs there)

    At my session at SQLBits IV on Visual Studio 2008 DBPro GDR it was mentioned that there was a major patch just about to be released to address some known issues. Well Brian Harry has provided links to the release of the release candidate of the GDR QFE

    Posted Apr 07 2009, 10:48 AM by Richard with no comments
    Filed under: , ,
  • Testing SharePoint Workflows using TypeMock Isolator (Part 2)

    Updated 12 June 2009 - I have been having problems using this technique of Typemock with Sharepoint Workflows, the workflows keep unexpectedly idling as opposed to activating. If you suffer similar problem please check for later posts as to any solutions I find. 


    After reading Gil’s blog on writing simpler tests I have done some tidying of the code from my previous post. In this version I have extracted the boiler plate code to run the workflow to a static helper method and modified my tests to incorporate Gil’s comments, they are certainly more readable.

       1: [TestMethod]
       2:       public void WorkFlowSwitchOnTitle_TitleStartsWithA_SetApprovelFieldAndUpdate()
       3:       {
       4:           // Arrange
       5:           var fakeProperties = Isolate.Fake.Instance<SPWorkflowActivationProperties>();
       6:           var fakeItem = fakeProperties.Item;
       7:           Isolate.WhenCalled(() => fakeItem.Title).WillReturn("ABC");
       8:  
       9:           // we actually don't need to create this field MOSS lets us attempt to write to
      10:           // it even if not declared, it would only need to be created if we check the value in the workflow
      11:           /*
      12:           var fakeField = fakeItem.Fields["Approved"];
      13:           fakeField.DefaultValue = false.ToString();
      14:           */
      15:  
      16:           // Act
      17:           WorkflowRunner(typeof(SharePointWorkflow.Workflow1),fakeProperties);
      18:           
      19:           // Assert
      20:           Isolate.Verify.WasCalledWithExactArguments(() => fakeItem.Update());
      21:           Isolate.Verify.WasCalledWithExactArguments(() => fakeItem["Approved"] = "True");
      22:  
      23:       }
      24:  
      25:       [TestMethod]
      26:       public void WorkFlowSwitchOnTitle_TitleStartsWithZ_DoNothing()
      27:       {
      28:           // Arrange
      29:           var fakeProperties = Isolate.Fake.Instance<SPWorkflowActivationProperties>();
      30:           var fakeItem = fakeProperties.Item;
      31:           Isolate.WhenCalled(() => fakeItem.Title).WillReturn("XYZ");
      32:  
      33:           // Act
      34:           WorkflowRunner(typeof(SharePointWorkflow.Workflow1),fakeProperties);
      35:  
      36:           // Assert
      37:           Isolate.Verify.WasNotCalled(() => fakeItem.Update());
      38:  
      39:       }
      40:  
      41:  
      42:  
      43:       /// <summary>
      44:       /// A helper method to run a workflow for a test
      45:       /// </summary>
      46:       /// <param name="wfType">The type of workflow to create</param>
      47:       /// <param name="fakeProperties">The fake properties used to create the workflow</param>
      48:       private static void WorkflowRunner(Type wfType, SPWorkflowActivationProperties fakeProperties)
      49:       {
      50:           using (WorkflowRuntime workflowRuntime = new WorkflowRuntime())
      51:           {
      52:               AutoResetEvent waitHandle = new AutoResetEvent(false);
      53:               workflowRuntime.WorkflowCompleted += delegate(object sender, WorkflowCompletedEventArgs e)
      54:               {
      55:                   // don't put asserts here as will be in the wrong thread
      56:                   waitHandle.Set();
      57:               };
      58:  
      59:               workflowRuntime.WorkflowTerminated += delegate(object sender, WorkflowTerminatedEventArgs e)
      60:               {
      61:                   // don't put asserts here as will be in the wrong thread
      62:                   waitHandle.Set();
      63:               };
      64:  
      65:               // when this is called the constructor is called twice
      66:               // the first time is for validation for the workflow in this appdomain see http://odetocode.com/Blogs/scott/archive/2006/03/30/3192.aspx
      67:               // then the real construction is run, the problem is this double run means that the Isolate.Swap.NextInstance
      68:               // fails as it attaches to the first validation create, not the second real one
      69:               WorkflowInstance instance = workflowRuntime.CreateWorkflow(wfType);
      70:  
      71:               // SO for this reason we only get the swap after the first create has beend one
      72:               Isolate.Swap.NextInstance<SPWorkflowActivationProperties>().With(fakeProperties);
      73:  
      74:               // we then recreate the workflow again, this time it has already been validated so
      75:               // so the swap works
      76:               instance = workflowRuntime.CreateWorkflow(wfType);
      77:  
      78:               instance.Start();
      79:  
      80:               waitHandle.WaitOne();
      81:  
      82:               // the workflow is finished assert could go here, but will be done
      83:               // in the calling method
      84:  
      85:           }
      86:       
      87:       }

    The workflow remains the same as in the previous post.

  • Speaking next week at Agile Yorkshire

    I am speaking in Wednesday the 8th at Agile Yorkshire, on Crystal Clear and lessons learnt in Agile projects. The user group is meeting at the Victoria Hotel in Leeds as usual, and thanks to our sponsors there is a free drink for all attendees.

    Hope to see you there.

  • Live Writer crashing when adding hyperlinks

    For a while I have had a problem that when I tried to add a hyperlink via the toolbar in Live Writer I get a dialog that Live Writer has stopped working, it doesn’t exit, it just des not open the modal window for adding a hyperlink. It was irritating, but as I could edit the HTML source and put in the link by hand I could not be bothered to work out how to fix it.

    Well today I wanted to add a new pluggin to Live Writer and it seem the options dialog suffers the same problem, so I had to fix it. I searched with Microsoft Live Search and it found nothing, so I tried with Google and found the solution on Tom Soisoonthorn’s blog , it is missing text in linkglossary.xml file.

    Update 5 Mar 09 – On checking the file linkglossary.xml again I think the reason Live Writer stopped working was the due to the installation of fiddler2, I can’t see why they are related, but it is in it’s configuration section the error lies.

    Beyond the fact that this fixed my problems, it is interesting to note this is the first time a good few months where I have not found what I wanted via Live Search – it is much improved, but Google still seems to get just that bit more.

More Posts Next page »
Black Marble 2004-2010
Powered by Community Server (Commercial Edition), by Telligent Systems