Skip to content

Commit

Permalink
.feature files are working like expected in silverlight projects
Browse files Browse the repository at this point in the history
added "mstest.silverlight" generator
  • Loading branch information
sztupi committed Jun 29, 2010
1 parent 13e0300 commit f4d4ff3
Show file tree
Hide file tree
Showing 7 changed files with 348 additions and 199 deletions.
11 changes: 7 additions & 4 deletions Generator/Configuration/GeneratorConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,13 @@ private void SetUnitTestDefaultsByName(string name)
break;
case "xunit":
GeneratorUnitTestProviderType = typeof(XUnitTestGeneratorProvider);
break;
case "mstest":
GeneratorUnitTestProviderType = typeof(MsTestGeneratorProvider);
break;
break;
case "mstest":
GeneratorUnitTestProviderType = typeof(MsTestGeneratorProvider);
break;
case "mstest.silverlight":
GeneratorUnitTestProviderType = typeof(MsTestSilverlightGeneratorProvider);
break;
default:
GeneratorUnitTestProviderType = null;
break;
Expand Down
187 changes: 94 additions & 93 deletions Generator/TechTalk.SpecFlow.Generator.csproj
Original file line number Diff line number Diff line change
@@ -1,100 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{453D8014-B6CD-4E86-80A8-D59F59092334}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechTalk.SpecFlow.Generator</RootNamespace>
<AssemblyName>TechTalk.SpecFlow.Generator</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\specflow.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Build.Engine" />
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Runtime\Configuration\ConfigDefaults.cs">
<Link>Configuration\ConfigDefaults.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\ConfigurationSectionHandler.cs">
<Link>Configuration\ConfigurationSectionHandler.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\ConfigurationServices.cs">
<Link>Configuration\ConfigurationServices.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\MissingOrPendingStepsOutcome.cs">
<Link>Configuration\MissingOrPendingStepsOutcome.cs</Link>
</Compile>
<Compile Include="..\Runtime\StringExtensions.cs">
<Link>StringExtensions.cs</Link>
</Compile>
<Compile Include="..\VersionInfo.cs">
<Link>VersionInfo.cs</Link>
</Compile>
<Compile Include="BatchGenerator.cs" />
<Compile Include="CodeDomHelper.cs" />
<Compile Include="Configuration\GeneratorConfiguration.cs" />
<Compile Include="Configuration\GeneratorConfigurationReader.cs" />
<Compile Include="Configuration\MsBuildProjectReader.cs" />
<Compile Include="Configuration\SpecFlowProject.cs" />
<Compile Include="UnitTestConverter\ISpecFlowUnitTestConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpecFlowGenerator.cs" />
<Compile Include="SpecFlowUnitTestConverter.cs" />
<Compile Include="UnitTestProvider\MbUnitTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\XUnitTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\IUnitTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\MsTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\NUnitTestConverter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Parser\TechTalk.SpecFlow.Parser.csproj">
<Project>{7CCEF6D6-FC17-422E-9BED-EDD752B6496F}</Project>
<Name>TechTalk.SpecFlow.Parser</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{453D8014-B6CD-4E86-80A8-D59F59092334}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechTalk.SpecFlow.Generator</RootNamespace>
<AssemblyName>TechTalk.SpecFlow.Generator</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\specflow.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Build.Engine" />
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Runtime\Configuration\ConfigDefaults.cs">
<Link>Configuration\ConfigDefaults.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\ConfigurationSectionHandler.cs">
<Link>Configuration\ConfigurationSectionHandler.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\ConfigurationServices.cs">
<Link>Configuration\ConfigurationServices.cs</Link>
</Compile>
<Compile Include="..\Runtime\Configuration\MissingOrPendingStepsOutcome.cs">
<Link>Configuration\MissingOrPendingStepsOutcome.cs</Link>
</Compile>
<Compile Include="..\Runtime\StringExtensions.cs">
<Link>StringExtensions.cs</Link>
</Compile>
<Compile Include="..\VersionInfo.cs">
<Link>VersionInfo.cs</Link>
</Compile>
<Compile Include="BatchGenerator.cs" />
<Compile Include="CodeDomHelper.cs" />
<Compile Include="Configuration\GeneratorConfiguration.cs" />
<Compile Include="Configuration\GeneratorConfigurationReader.cs" />
<Compile Include="Configuration\MsBuildProjectReader.cs" />
<Compile Include="Configuration\SpecFlowProject.cs" />
<Compile Include="UnitTestConverter\ISpecFlowUnitTestConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SpecFlowGenerator.cs" />
<Compile Include="SpecFlowUnitTestConverter.cs" />
<Compile Include="UnitTestProvider\MsTestSilverlightGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\MbUnitTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\XUnitTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\IUnitTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\MsTestGeneratorProvider.cs" />
<Compile Include="UnitTestProvider\NUnitTestConverter.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Parser\TechTalk.SpecFlow.Parser.csproj">
<Project>{7CCEF6D6-FC17-422E-9BED-EDD752B6496F}</Project>
<Name>TechTalk.SpecFlow.Parser</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
-->
</Project>
124 changes: 124 additions & 0 deletions Generator/UnitTestProvider/MsTestSilverlightGeneratorProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using System.CodeDom;
using System.Collections.Generic;

namespace TechTalk.SpecFlow.Generator.UnitTestProvider
{
// TODO: it's an ugly copy-paste of MsTestGeneratorProvider - we should consider refactoring the generator creation to support custom factories.
public class MsTestSilverlightGeneratorProvider : IUnitTestGeneratorProvider
{
private const string TESTFIXTURE_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute";
private const string TEST_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestMethodAttribute";
private const string PROPERTY_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestPropertyAttribute";
private const string TESTFIXTURESETUP_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.ClassInitializeAttribute";
private const string TESTFIXTURETEARDOWN_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.ClassCleanupAttribute";
private const string TESTSETUP_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestInitializeAttribute";
private const string TESTTEARDOWN_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.TestCleanupAttribute";
private const string IGNORE_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.IgnoreAttribute";
private const string DESCRIPTION_ATTR = "Microsoft.VisualStudio.TestTools.UnitTesting.DescriptionAttribute";

private const string FEATURE_TITILE_PROPERTY_NAME = "FeatureTitle";
private const string FEATURE_TITILE_KEY = "FeatureTitle";

private const string TESTCONTEXT_TYPE = "Microsoft.VisualStudio.TestTools.UnitTesting.TestContext";

private CodeTypeDeclaration currentTestTypeDeclaration = null;

public void SetTestFixture(CodeTypeDeclaration typeDeclaration, string title, string description)
{
typeDeclaration.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTFIXTURE_ATTR)));

//as in mstest, you cannot mark classes with the description attribute, we
//just remember the feature title, and we will apply it for each test method
typeDeclaration.UserData[FEATURE_TITILE_KEY] = title;

currentTestTypeDeclaration = typeDeclaration;
}

private void SetDescription(CodeAttributeDeclarationCollection customAttributes, string description)
{
customAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(DESCRIPTION_ATTR),
new CodeAttributeArgument(
new CodePrimitiveExpression(description))));
}

private void SetProperty(CodeAttributeDeclarationCollection customAttributes, string name, string value)
{
customAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(PROPERTY_ATTR),
new CodeAttributeArgument(
new CodePrimitiveExpression(name)),
new CodeAttributeArgument(
new CodePrimitiveExpression(value))));
}

public void SetTestFixtureCategories(CodeTypeDeclaration typeDeclaration, IEnumerable<string> categories)
{
//MsTest does not support caregories... :(
}

public void SetTest(CodeMemberMethod memberMethod, string title)
{
memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TEST_ATTR)));

SetDescription(memberMethod.CustomAttributes, title);

if (currentTestTypeDeclaration == null)
return;

string featureTitle = currentTestTypeDeclaration.UserData[FEATURE_TITILE_KEY] as string;
if (featureTitle != null)
SetProperty(memberMethod.CustomAttributes, FEATURE_TITILE_PROPERTY_NAME, featureTitle);
}

public void SetTestCategories(CodeMemberMethod memberMethod, IEnumerable<string> categories)
{
//MsTest does not support caregories... :(
}

public void SetTestSetup(CodeMemberMethod memberMethod)
{
memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTSETUP_ATTR)));
}

public void SetTestFixtureSetup(CodeMemberMethod memberMethod)
{
memberMethod.Attributes |= MemberAttributes.Static;

memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTFIXTURESETUP_ATTR)));
}

public void SetTestFixtureTearDown(CodeMemberMethod memberMethod)
{
memberMethod.Attributes |= MemberAttributes.Static;

memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTFIXTURETEARDOWN_ATTR)));
}

public void SetTestTearDown(CodeMemberMethod memberMethod)
{
memberMethod.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(TESTTEARDOWN_ATTR)));
}

public void SetIgnore(CodeTypeMember codeTypeMember)
{
codeTypeMember.CustomAttributes.Add(
new CodeAttributeDeclaration(
new CodeTypeReference(IGNORE_ATTR)));
}
}
}
1 change: 1 addition & 0 deletions Installer/SpecFlowInstaller/Common.wxi
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
<?define CLSID_SpecFlowSingleFileGenerator = "{3c9cf10a-a9ab-4899-a0fb-4b3be4a36c15}" ?>
<?define VBLangId = "{164B10B9-B200-11D0-8C61-00A0C91E29D5}" ?>
<?define CSharpLangId = "{FAE04EC1-301F-11D3-BF4B-00C04F79EFBC}" ?>
<?define SilverlightPackageId = "{CB22EE0E-4072-4ae7-96E2-90FCCF879544}" ?>

</Include>
27 changes: 15 additions & 12 deletions Installer/SpecFlowInstaller/Product.Generated.wxs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<?xml version='1.0' encoding='UTF-8'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<ComponentGroup Id="Product.Generated">
<ComponentGroupRef Id="TechTalk.SpecFlow.Generator.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Parser.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Reporting.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Tools.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.VsIntegration.Binaries" />
</ComponentGroup>
</Fragment>
<?xml version='1.0' encoding='UTF-8'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<ComponentGroup Id="Product.Generated">
<ComponentGroupRef Id="TechTalk.SpecFlow.Generator.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Parser.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Reporting.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Silverlight.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Silverlight.Content" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Silverlight.Satellites" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.Tools.Binaries" />
<ComponentGroupRef Id="TechTalk.SpecFlow.VsIntegration.Binaries" />
</ComponentGroup>
</Fragment>
</Wix>
Loading

0 comments on commit f4d4ff3

Please sign in to comment.