0

I've been searching Google, reading various questions (and answers) here on Stack Overflow, and scanning the SlowCheetah NuGet page, the GitHub issues list, and the utility author's blog, and I still can't find an answer to figure out exactly what's causing my problems.

I have a solution hosted in a TFS 2013 Git repository. When a particular branch is pushed to the TFS server, it kicks off an automated build and deployment to a build site. All of that is working great. It also kicks off all of the unit tests and everything runs without issue.

That is, until I get to the SpecFlow WatiN tests...

The tests get kicked off without an issue, and I have the server set up to run the WatiN tests interactively within the browser. That all works. The problem is that the site the WatiN tests hit are on the Build server, which is a different URL than what I use locally on my development box (and also from the testing server, which is a third URL). I have the site URL set up in the App.Config of the unit test project (which is an MSTest-based project). I also have XDT transformation files set up for each of our target environments, including the Build environment in question.

When I do a push to TFS, or manually start a build, everything runs fine until it gets to the SpecFlow tests. These particular tests start, and if I'm actually logged into the VM-hosted server that acts as the build server when the build and tests are running AS THE Build/Test user, I can actually see the browser start up. I can also see, briefly, the "This page can’t be displayed" message in Internet Explorer, which is not the expected behavior (I should see the app's login page) and the test fails.

Looking at it a bit further, I started with the obvious - is it hitting the right site? Well, digging into the build folder on the server, I was able to verify that the transformation is NOT working - the app.config file has the site URL for the development machine and not the one for the Build environment!

The transformations for the web project ARE working - the changes for the Build environment are being populated for the front-end web application and the back-end service tier application and they work - I can bring up the site on the build server in a browser. But these projects are not using SlowCheetah, but rather the build-in web.config transformations. The unit test project DOES have the SlowCheetah NuGet package installed; it just doesn't seem to be working for whatever reason.

Here's the app.config file for the unit test project in question:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>

  <appSettings>
    <add key="SiteUrl" value="http://dev.server.url/" />
  </appSettings>

  <!-- Spec-Flow Configuration -->
  <specFlow>
    <unitTestProvider name="MsTest" />
  </specFlow>

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="DocumentFormat.OpenXml" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.5022.0" newVersion="2.0.5022.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

The configuration transformation file app.Build.config is as follows:

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <appSettings>
    <add key="SiteUrl" xdt:Locator="Match(key)" xdt:Transform="SetAttributes" value="http://build.server.url/" />
  </appSettings>
</configuration>

These configuration files look OK to me, so I don't think there's an issue with the format of the files. I can also verify that the SpecFlow tests run and pass when I run them manually on my local development box. My guess is that either the transformation simply isn't being kicked off, or maybe there's something in the timeline of when the transformations are run and when the unit tests are run.

What am I doing wrong here? Any assistance is greatly appreciated!

1 Answers1

0

In your Build Definition you probably defined the Configurations to use. Part of that also defines a Platform like Any CPU or x86. As it turns out in the solution the Platform Any CPU has a space where in the project files the Platform AnyCPU does not have a space.

I found the best way to get around this was to leave the Platform blank and only put in the configuration name. VS will pop up a warning letting you know that there is data missing, you can just hit Yes to save it anyways. Alternatively you can just type in your configurations like the following |Release,|Debug.

The pattern is [PlatformName]|[ConfigurationName],[PlatformName]|[ConfigurationName],...

spam1923
  • 61
  • 4