FitNesse configuration files - configuration

I'm using FitNesse as a functional testing framework. I'm running into trouble when FitNesse runs code that needs configuration.
If I need to get a connection string from the configuration file, I can get it to work by adding it to the FitServer.exe.config. However, I don't like that solution. I would like FitNesse to load my own configuration file, namely TheNameOfMyApp.dll.config.
Is this possible?

Sure, easy to do. I'm assuming you're using the dotnet or dotnet2 test runner. I'm using the dotnet2 test runner, and here's how I've got it set up:
First, when you !define your COMMAND_PATTERN, include -c suite.config. For instance, I have the following in root:
!define COMMAND_PATTERN {%m -c suite.config %p}
!define TEST_RUNNER {..\..\bin\Debug\FitServer.exe}
suite.config goes in the same dir as fitnesse.jar:
<suiteConfig>
<fit.Settings>
<appConfigFile>..\..\MyProjectFolder\fitnesse\MyProjectName.config</appConfigFile>
</fit.Settings>
<fit.Assemblies>
</fit.Assemblies>
<fit.FileExclusions>
<add>^\.svn$</add>
</fit.FileExclusions>
<fit.Namespaces>
</fit.Namespaces>
<fit.CellHandlers>
</fit.CellHandlers>
<fitlibrary.CellHandlers>
</fitlibrary.CellHandlers>
</suiteConfig>
MyProjectName.config looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="keyname" value="something" />
</appSettings>
</configuration>
You can make things easier for yourself if you use an absolute path for the appConfigFile. I started off with an absolute path, got things working, then switched to a relative path by trial and error.
Note that I'm running my test runner from a non-standard location, which will affect the relative path in suite.config. The path is relative to your TEST_RUNNER location, NOT to suite.config or fitnesse.jar.

yes it is possible but an awful load of work. you need to define a test-project where you have your tests in it and a "wrapper"-project where you have the functionality of providing the tests with data and configuration settings.

Related

How do I tell MSDeploy to deploy a package using a manifest?

I have a TeamCity build that creates a package by running the following:
msdeploy -verb:sync -source:contentPath=C:\path\to\files\myFilesToDeploy -dest:package=C:\path\to\packages\filesToDeployPackage.zip
Now I want to deploy this package and its contents to a few servers, but I want to do it using a manifest:
msdeploy -verb:sync -source:package=C:\path\to\packages\filesToDeployPackage.zip -dest:manifest=C:\path\to\manifests\destManifest.xml
destManifest.xml contains:
<?xml version="1.0" encoding="UTF-8"?>
<sitemanifest>
<contentPath path="\\machineNetworkName\path\to\final\content"/>
</sitemanifest>
But this gets me the following error:
Error: Source (contentPath) and destination (sitemanifest) are not compatible for the given operation.
The only way that I managed to have something work was by having 2 manifests, one for source and one for dest, and use contentPath on both XMLs, but then I can't use the package that my build produces. This case requires that folders are uncompressed first. Also I don't like having 2 manifests, I want to solve this with a single manifest.
I've checked Microsoft's docs and other threads and I can't find an example of this. Any hints?

What manifest visual studio is using to generate msdeploy package

I want to package a folder with msdeploy.exe to a zip destination at the end of CI process.
I run the following command line
msdeploy.exe -verb:sync -source:contentpath="C:\SampleWebApp" -dest:package="c:\SampleWebApp.zip" -declareParamFile="parameters.xml"
I also like the *.deploy.cmd and *.SetParameters.xml which msbuild generates when it spits out a deployment package. I renamed the one set of *.deploy.cmd and *.SetParameters.xml file and changed the content accordingly. to be able to run in deployment environment.
When I run *.deploy.cmd file it generates the folder "C:\SampleWebApp" rather than creating the iis app based on parameters provided in .SetParameter.xml.
After some investigation, I've found that the .cmd deploys to -dest:auto which is good. but apparently my package manifest inside the package indicates that this package is contentPath whereas packages generated by msbuild has more complex manifest in archive.xml inside package using iisApp provider.
Having looked at following post
http://blogs.msdn.com/b/webdev/archive/2013/01/09/real-scenario-folder-deployment-scenarios-with-msdeploy.aspx
I believe if I use -source:manifest="Package.xml" with right Package.xml the end result should be similar to VS package output
The I thought maybe the *.SourceManifest.xml is the manifest for the package. I used and it builds the package but when I want to deploy that to the using .deploy.cmd it complains about setAclUser
Error: A value for the 'setAclUser' setting must be specified when the
'setAcl' provider is used with a physical path.
Does anybody know that is the manifest msbuild uses?
To directly answer your question: the manifest is generated dynamically based on MsDeploySourceManifest MSBuild items.
You can make it use contentPath rather than iisApp by declaring DeployAsIisApp=false in your publish profile (or command line /p:DeployAsIisApp=false). This will also disable the setAcl providers.
If you want to keep iisApp, you can disable the ACL providers...
... being added to the package by declaring IncludeSetAclProviderOnDestination=false in your publish profile
... being deployed by passing /I:False to deploy.cmd
Following is the manifest template
<?xml version="1.0" encoding="utf-8"?>
<sitemanifest>
<iisApp path="[PATH1]"/>
</sitemanifest>
and Parameter.xml template
<parameters>
<parameter name="IIS Web Application Name" defaultValue="WEBSITENAME" tags="IisApp">
<parameterEntry kind="ProviderPath" scope="IisApp" match="^[PATH1ESCAPED]$" />
</parameter>
<!-- appSetting section-->
</parameters>
note: [PATH1] should be replaced with your folder path like C:\MY.FOLDER\WWW
and [PATH1ESCAPED] should be same path but escaped with postfix and prefix ^ $ like
^C:\MY.FOLDER\WWW$
Then you can call
"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:manifest="Manifest.xml" -dest:package=%1 -declareParamFile="parameters.xml"
and %1 being folder path like C:\MY.FOLDER\WWW

CruiseControl unable to recognize modifications for Mercurial repository

I am trying to implement a continuous build stack, and decided to use CruiseControl with Ant. However, it seems that CruiseControl is having problem picking up the changes from my Mercurial directory. Here's some code from config.xml with a bunch of unnecessary elements taken out. One workaround I found was to set requiremodification to false, which will build the software regardless of the changes made. Am I missing something here? Or is this a bug of CruiseControl.
<!--config.xml-->
<project name="test_runner" buildafterfailed="false"
requiremodification="true" forceonly="${test_runner.inactive}">
<listeners>
<currentbuildstatuslistener file="${projectLogsDir}/status.txt" />
</listeners>
<bootstrappers>
</bootstrappers>
<modificationset quietperiod="${quietPeriod}">
<mercurial localworkingcopy="${mercurialDir}/solution1" property="solution1_changed" />
</modificationset>
<schedule interval="${scheduleInterval}">
<ant liveOutput="true" />
</schedule>
</project>
In CruiseControl.Net the server logs which command it performs to check for changes. You can check if this command is correct by running it yourself on the command line. I had the same issue with Perforce, and by running the command myself I found out that I had configured an incorrect view.
Note that I'm much more familiar with CruiseControl.Net than CruiseControl, so this might not apply to CruiseControl.

Azure Worker Role configuration issue while using SlowCheetah with custom config

We are using Nlog as logging tool with our Worker Role of Azure app.
It requires NLog.config file. We installed "SlowCheetah - XML Transforms", and have two Debug/Release transforms).
Solution does get rebuild successfully.
But when I try to run, I am getting following error. (I used exact transformation for nolog.config in one of my Windows service app, and it is working fine there).
Error 163 The item "bin\Debug\NLog.config" in item list "OutputGroups"
does not define a value for metadata "TargetPath". In order to use
this metadata, either qualify it by specifying
%(OutputGroups.TargetPath), or ensure that all items in this list
define a value for this metadata. C:\Program Files
(x86)\MSBuild\Microsoft\VisualStudio\v10.0\Windows Azure
Tools\1.6\Microsoft.WindowsAzure.targets 2299 5 Insight.CloudWeb
I don't know if this is done by the SlowCheetah extension, but could you verify if your *.csproj file contains the AfterCompile target similar to this?
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<UsingTask TaskName="TransformXml"
AssemblyFile="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll" />
<Target Name="AfterCompile" Condition="exists(’app.$(Configuration).config’)">
<TransformXml Source="NLog.config"
Destination="$(IntermediateOutputPath)$(TargetFileName).config"
Transform="NLog.$(Configuration).config" />
<ItemGroup>
<AppConfigWithTargetPath Remove="NLog.config"/>
<AppConfigWithTargetPath Include="$(IntermediateOutputPath)$(TargetFileName).config">
<TargetPath>$(TargetFileName).config</TargetPath>
</AppConfigWithTargetPath>
</ItemGroup>
</Target>
Take a look at Oleg's blog post .Config File Transformation under App.config File Transformation for more information.
I have a fix for this. Now you should be able to transform app.config as well as other XML files for Azure Worker Roles using SlowCheetah. Once I get the fix verified I will release the update to the VS gallery.
If you would like to try the fix you can download the updated VSIX at https://dl.dropbox.com/u/40134810/SlowCheetah/issue-44/SlowCheetah-issue-44.zip. If you are interested in following up on this please use the issue #44.

How to pass relative path in appsetting

i have following code and when i pass absolute path my project works but i need relative path configuration.ini is a file which is in my current project so when i give absolute path, like this ,the code never runs
<app Settings
<add key="Configuration Path" value="d:DocsWcfService\Configuration.INI"/>
</app Settings
i need something like this ,is there any way?
<app Settings
<add key="Configuration Path" value="~\Configuration.INI"/>
</app Settings
Server.MapPath
var physicalPath = Server.MapPath("~\Configuration.ini");
I had the same problem for config file before. I was able to use full path and it was working fine. When I try to use relative path , it wasn't able to find my config file. I hope my solution helps you or at least give you an idea.
Try to click file located in the solution expllorer and expand the properties tab to change 'copy to output directory' as 'Copy Always' . As I know VS copy to file to \bin\Debug folder every time when we run the project, so the relative path of that file will always be the same during development as well as after deployment.
After that below code will be enough
<app Settings
<add key="Configuration Path" value="Configuration.INI"/>
</app Settings