How to reuse Specflow steps from a CodedUITest project in different solution - coded-ui-tests

We have Specflow layer on top of our CodedUITest project. We have some common steps in one CodedUITest project(CodedUITestProject1), which we want to use in another CodedUITest project (CodedUITestProejct2) in different solution.
We have created dll of the CodedUITestProject1 and added its reference in CodedUITestProejct2. Also updated the CodedUITestProject2's App.config file to use bindings from External Assembly like this, but is not working. Any thoughts on this.
<specFlow>
<!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config -->
<!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --><unitTestProvider name="MsTest" />
<plugins>
<add name="CodedUi" type="Generator" path="." />
</plugins>
<stepAssemblies>
<stepAssembly assembly="CodedUITestProject1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
</stepAssemblies>
</specFlow>

The Visual Studio Integration has some bugs when it comes to additional step assemblies.
So syntax highlighting, IntelliSense and "Go To Definition" can sometimes not work.
Try to delete the specflow-stepmap* files from %temp%.
There are no problems at runtime.

Sometimes VS decides on its own to not copy the referenced DLL if no code usages are done in the consuming project.
Double check your bin folder for CodedUITestProject1.dll it should be missing if VS has decided that you don't need it.
If this is the case then you may need to create a dummy instance of a type from CodedUITestProject1.dll in your hooks (or anywhere in the code) so VS can see that you are using something from CodedUITestProject1.dll. Once the project is built then you may remove the dummy code you have entered.
Another option could be just to References -> CodedUITestProject1 -> Properties-> Set copy local to True. (not confirmed its fixing the problem).
Note: When using BDD steps from external DLL navigation (F12 on a step) is not working.

Related

Website project: want to generate XML documentation on build

For legacy reasons, I'm maintaining a Web Site Project for which I want to provide up-to-date documentation from the XML documentation comments. I gather I can do that by tweaking the <compilers> section in web.config. I finally reached this point:
<system.codedom>
<compilers>
<compiler
language="c#;cs;csharp"
extension=".cs"
type="Microsoft.CSharp.CSharpCodeProvider"
compilerOptions="/optimize /doc:C:\temp\my-output-here.xml"
warningLevel="1" />
</compilers>
</system.codedom>
Now when I start the website with (and thus invoke just-in-time compilation) I do get an XML file in the requested location but it's minimal:
<?xml version="1.0"?>
<doc>
<assembly>
<name>App_global.asax.abqhzva4</name>
</assembly>
<members>
</members>
</doc>
It seems like the <compiler> tag doesn't quite do what I want. It must be generating XML for the project folder itself rather than the .cs files, or it's getting overwritten with each compilation unit and I'm only seeing the trivial last one, or... I don't know. I'm not sure. This config tag is not well documented.
Long story short, I'm looking for a way to get XML documentation for all the .cs files in this website project. It doesn't matter if it's all in one file, in separate files, or even shoved into memory at run time.
I'm aware of the prior question on this, but the link provided there has been redirected to the Sandcastle site. That's great, but it's way more than I'm actually going to use on this project. Simply getting XML documentation at build time or run time is all that is necessary.
My question then is: What do I need to do to get the <compiler> config entry to generate XML docs for a Website Project?
I have an ugly workaround as well... But here goes!
1. Download the latest Sandcastle Installer from this page - https://github.com/EWSoftware/SHFB/releases
2. Unzip and run the installer
3. Copy EWSoftware.CodeDom.dll into your website's \bin directory. The default location of this file is - C:\Program Files (x86)\EWSoftware\Sandcastle Help File Builder\Extras\EWSoftware.CodeDom.dll
4. Modify web.config as follows:
<configuration>
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs"
compilerOptions="/docpath:C:\Publish\Docs"
type="EWSoftware.CodeDom.CSharpCodeProviderWithDocs, EWSoftware.CodeDom"
>
<!-- NOTE: Change version value as needed (v3.5, v4.0, etc.) -->
<providerOption name="CompilerVersion" value="v4.0"/>
</compiler>
</compilers>
</system.codedom>
</configuration>
Source: http://ewsoftware.github.io/EWSoftwareCodeDom/html/40ba6bda-95d6-4a64-834f-f7cedcb589d1.htm
5. Rebuild your solution and voila! The folder specified with the /docpath option will contain your XML documentation.

Conditionally exclude project from Visual Studio build

I have a Visual Studio 2012 library project (VC++) that includes certain classes if a certain SDK is available. I implemented this via msbuild Conditions in a property sheet:
<Choose>
<When Condition="Exists('C:\OFED_SDK\')">
<PropertyGroup>
<OfedSdkDir>C:\OFED_SDK\</OfedSdkDir>
</PropertyGroup>
</When>
</Choose>
[...]
<ItemDefinitionGroup Condition="$(OfedSdkDir) != ''">
<ClCompile>
<AdditionalIncludeDirectories>$(OfedSdkDir)Inc\; %(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>HAVE_OFED_SDK; %(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
[...]
Certain functionality is only available if HAVE_OFED_SDK is defined. This works perfectly.
The solution furthermore contains several projects for testing the library project. The test for the classes compiled conditionally are in a separate project.
My question is: Can I build this project depending on whether the above-mentioned condition (Condition="$(OfedSdkDir) != '' is true? If so, how would I do that? I need a solution that also works when building from VS.
Edit: I am aware of the solution Martin proposed, but I am looking for a solution that is working programmatically, ie which does not allow the user to enable the "wrong" configuration via the GUI.
Edit: I found that I can add (Condition="$(OfedSdkDir) != '' to the ClCompile of the source file which almost achieves what I want, but still runs the build process for the project.
Just setup a different solution configuration that doesn't attempt to build the relevant projects that you want to exclude.
For example, call it "Release-No-OFED" and un-tick those projects from being compiled in that configuration.

MonoTouch Linking Native References in Debug only

I have a MonoTouch project where I want to include a reference to some native ios libraries that are only used for testing & debugging. I do not need these refereces to be compiled into the release build.
I've tried editing the .csproj file to have a Condition for the ItemGroup that links in the Native References, but they seem to be ignored.
<ItemGroup Condition=" '$(Configuration)' == 'Debug' ">
<NativeReference Include="some path">
<IsCxx>false</IsCxx>
<Kind>Static</Kind>
</NativeReference>
I suppose there could be some way using the Additional mtouch arguments option in the project Options window. I am unsure though.
Does anyone know how I can link a native reference for a specific build configuration only in MonoDevelop?
MonoDevelop let you provide different Addtional mtouch arguments for every configuration it defines for your project. In general it means each of the four: [Debug|Release]|iPhone[Simulator] could use different settings.
If you're manually adding a static library then it's easy to add (or remove) it from a specific target.
However if you're using bindings made with the new [LinkWith] support then those additional arguments are automagically made for you. There could be ways to hack around this (e.g. changing the Build Action) but I did not try them out.

Custom aspx workflow form problem in WSPBuilder project

I have a working wss3.0 + workflow solution, with some aspx forms (followed Robert Shelton’s tutorial) and some document libraries. I would like to deploy it with WSPBuilder but I have stuck hopeless.
The transformation of the workflow was 5 minutes, but I cannot transform workflow-forms at all. I have tried every way I found, but symptoms are constantly same:
The compiler at the codebehind file says “The name 'myAspxTextControl’ does not exist in the current context” for every controls defined in the aspx file.
I tired to connect them on the following ways:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs"
Inherits="SWEF_WSP.Test, SWEF_WSP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c935c51f6d8e9562" %>
Where SWEF_WSP.dll is my WSPBuilder projects assembly, SWEF_SWP is the namespace, Test.aspx and Test.aspx.cs are my form files demonstrating the issue.
I tried it with and without Codebehind field, and using separate #Asssembly directive too, and changed the the place of these files (in the Layout folder in 12 hive or not ), together, or not, the error is same.
I followed the
http://www.greggalipeau.com/2008/05/23/moving-a-sharepoint-workflow-between-solutions/
(and some more)
But unfortunately didn’t find any buildable example.
I must miss something very evident,
Any help would be greatly appreciated ...‎
bts
Looks like you are missing the .designer.cs file for the page - Visual studio won't generate it since the project is a workflow, not a website.

Add Visual C++ property sheets using CMake

I'm currently porting a gcc project to Visual C++. It's defined in a CMake file, and I have created a Visual C++ property sheet to aid in compatibility (GccCompat.props). Everytime the Visual C++ project files are regenerated by CMake, the property sheet has to be added manually, since I don't know how to add it automatically. So, the question is:
How can I tell CMake to add a property sheet to the generated Visual C++ solution?
This functionality has made it into the nightly build of CMake (https://gitlab.kitware.com/cmake/cmake/commit/e390991846825799e619e072a28f1da58b7c89ba), although not into a stable release yet. Theoretically, it will be in the next release, and CMake releases are made relatively frequently.
To use, you would set the VS_USER_PROPS property on a target. Eg. set_target_properties(foo PROPERTIES VS_USER_PROPS "${props_file}").
However, it doesn't appear that you can use multiple property sheets with this option, and, it replaces the default user property file ($(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props). To workaround this, property sheets can include other property sheets, so, you could make a 'master' property sheet which includes any other property sheets that you would like to use (including the default user property sheet).
This question is a little bit old but I have recently stumbled upon the same problem while integrating GStreamer into my project. GStreamer comes with a set of extremely well prepared and high quality Property Sheets and I wanted to use them instead of hacking things around in CMake.
Fortunately, this issue is only limited to Windows and Visual Studio. So here's my solution:
The idea is to use Visual Studio's .user file feature. CMake does not generate this file so it's pretty safe to generate it at configure-time. At configure time you may generate a file that has the EXACT name as your project file but ends with a .user extension.
Partial Solution:
If your project file is named my_project.vcxproj, you need to create another file next to it called my_project.vcxproj.user. According to MSDN:
A user file (.vcxproj.user) stores user-specific properties, for
example, debugging and deployment settings. The vcxproj.user file
applies to all projects for a particular user.
The contents of this file for importing property sheets is something like this:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="/path/to/sheet1.props" />
<Import Project="/path/to/sheet2.props" />
</Project>
Not flawless, but works until CMake starts supporting property sheets. The file can be created by using CMake's file command at configure-time.
Potential Caveat:
I have noticed when I add property sheets this way, sometimes they do not show in the Property Manager window (might be a bug in Visual Studio Community 2013) but they always are imported properly and dependencies are resolved correctly.
Not sure which properties you need. A few could be set directly in CMake, like in this example for multiple configurations:
set (CMAKE_CONFIGURATION_TYPES "A;B;C;D" CACHE STRING "Configurations" FORCE)
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} )
set (CMAKE_CXX_FLAGS_${OUTPUTCONFIG} "/ZI /Od")
set (CMAKE_EXE_LINKER_FLAGS_${OUTPUTCONFIG} "/debug")
endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES )
Apart from variables listed here, I think CMake has no possibility to attach property sheets.
in my master props file main.props:
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
then, in CMakeLists.txt:
set_target_properties(foo PROPERTIES VS_USER_PROPS "main.props")

Resources