New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for MsTest's DeploymentItemAttribute #803

Closed
icnocop opened this Issue Mar 10, 2017 · 11 comments

Comments

Projects
None yet
5 participants
@icnocop
Contributor

icnocop commented Mar 10, 2017

Hi.

I'd like to request the ability to support MsTest's DeploymentItemAttribute.

For example, I'd like to be able to declare the DeploymentItemAttribute on a SpecFlow hook class and have that emitted in the generated test class:

DeploymentItem.feature:

Feature: Deployment Item

Scenario: Test
  Then the file "test.txt" exists

FileSteps.cs:

    [Binding]
    [DeploymentItem("test.txt")]
    public class FileSteps
    {
        [Then(@"the file ""(.*)"" exists")]
        public void ThenTheFileExists(string fileName)
        {
            Assert.IsTrue(File.Exists(fileName));
        }
    }

In this example and ideally, any scenario that uses a step (or has a tag) defined within a class that has the DeploymentItemAttribute should have the same DeploymentItemAttribute emitted in the generated class.

Another example (but less personally desired) could be with the use of a tag as described here:
http://dreadjr.blogspot.com/2012/03/specflow-msttest-deploymentitemattribut.html

Thank you.

@samholder

This comment has been minimized.

Show comment
Hide comment
@samholder

samholder Mar 20, 2017

Contributor
Contributor

samholder commented Mar 20, 2017

@icnocop

This comment has been minimized.

Show comment
Hide comment
@icnocop

icnocop Mar 21, 2017

Contributor

Thank you, @samholder.

That's what I'm currently doing and with the changes in my pull request, deploying files will be even easier. 😃

Contributor

icnocop commented Mar 21, 2017

Thank you, @samholder.

That's what I'm currently doing and with the changes in my pull request, deploying files will be even easier. 😃

@icnocop

This comment has been minimized.

Show comment
Hide comment
@icnocop

icnocop Apr 12, 2017

Contributor

I created pull request #805, still waiting for it to get accepted/merged. 😄

Contributor

icnocop commented Apr 12, 2017

I created pull request #805, still waiting for it to get accepted/merged. 😄

@SabotageAndi

This comment has been minimized.

Show comment
Hide comment
@SabotageAndi

SabotageAndi Apr 13, 2017

Collaborator

@icnocop Sorry about the delay.
@gasparnagy and I were very busy in the last weeks and didn't had that much time for SpecFlow we would like to have.

Collaborator

SabotageAndi commented Apr 13, 2017

@icnocop Sorry about the delay.
@gasparnagy and I were very busy in the last weeks and didn't had that much time for SpecFlow we would like to have.

SabotageAndi added a commit that referenced this issue Apr 13, 2017

Added support for MsTest's [DeploymentItem] attribute with @mstest:De…
…ploymentItem tag (#805)

* Added support for MsTest's [DeploymentItem] attribute with @deploy tag (Issue #803)
* Prefixing new tag with `MsTest:`
* using pascal case @mstest:DeploymentItem
* wrapping nested using blocks with curly brackets
@SabotageAndi

This comment has been minimized.

Show comment
Hide comment
@SabotageAndi

SabotageAndi Apr 13, 2017

Collaborator

Resolved by #805

Collaborator

SabotageAndi commented Apr 13, 2017

Resolved by #805

@SalamiArmy

This comment has been minimized.

Show comment
Hide comment
@SalamiArmy

SalamiArmy Jul 17, 2017

This feature of 2.2.0 is really not working for me... I can't get the deployment item attribute to generate with SpecFlow 2.2.0.
In 2.1.0 it does generate a test category attribute like this:
[Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("MsTest:DeploymentItem:test.txt")]
But that same feature file when regenerated with 2.2.0 doesn't generate a deployment item attribute or that test category attribute, it just quietly ignores all "@mstest:DeploymentItem:" tags. I expect that test category attribute to change to a deployment item attribute like this:
[Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItem("test.txt")]
when regenerating using SpecFlow 2.2.0.

Is that not how this feature is supposed to work? I've looked through pull request #805 and I see that it is case insensitive, so it's not that. I also see changes to MsTest2010GeneratorProvider.cs my generated SpecFlow feature file says "SpecFlow Generator Version:2.2.0.0" at the top but is it using the correct generator provider I wonder? Or are these changes to the generator provider for MSTest not been released yet?

EDIT: My powershell workaround:
foreach ($FeatureFile in (Get-ChildItem "$PSScriptRoot\**\*.feature.cs")) { (Get-Content $FeatureFile).replace('TestCategoryAttribute("MSTest:DeploymentItem:', 'DeploymentItem("') | Set-Content $FeatureFile }

SalamiArmy commented Jul 17, 2017

This feature of 2.2.0 is really not working for me... I can't get the deployment item attribute to generate with SpecFlow 2.2.0.
In 2.1.0 it does generate a test category attribute like this:
[Microsoft.VisualStudio.TestTools.UnitTesting.TestCategoryAttribute("MsTest:DeploymentItem:test.txt")]
But that same feature file when regenerated with 2.2.0 doesn't generate a deployment item attribute or that test category attribute, it just quietly ignores all "@mstest:DeploymentItem:" tags. I expect that test category attribute to change to a deployment item attribute like this:
[Microsoft.VisualStudio.TestTools.UnitTesting.DeploymentItem("test.txt")]
when regenerating using SpecFlow 2.2.0.

Is that not how this feature is supposed to work? I've looked through pull request #805 and I see that it is case insensitive, so it's not that. I also see changes to MsTest2010GeneratorProvider.cs my generated SpecFlow feature file says "SpecFlow Generator Version:2.2.0.0" at the top but is it using the correct generator provider I wonder? Or are these changes to the generator provider for MSTest not been released yet?

EDIT: My powershell workaround:
foreach ($FeatureFile in (Get-ChildItem "$PSScriptRoot\**\*.feature.cs")) { (Get-Content $FeatureFile).replace('TestCategoryAttribute("MSTest:DeploymentItem:', 'DeploymentItem("') | Set-Content $FeatureFile }

@gasparnagy

This comment has been minimized.

Show comment
Hide comment
@gasparnagy

gasparnagy Jul 27, 2017

Collaborator

@SalamiArmy This has been released. Did you specify the tag on the Feature? As far as I see this works only on feature level, not scenario level.

Collaborator

gasparnagy commented Jul 27, 2017

@SalamiArmy This has been released. Did you specify the tag on the Feature? As far as I see this works only on feature level, not scenario level.

@SalamiArmy

This comment has been minimized.

Show comment
Hide comment
@SalamiArmy

SalamiArmy Aug 4, 2017

Yes, in version 2.2.0...

For anyone interested, my experience was, if I put the tags on a scenario they are completely ignored, it wasn't user friendly. if I put them on a feature they were applied as deployment item attributes to all scenarios in in the feature. Which would make it impossible to apply to just select scenarios, like for example, as an optimization.

Yes, in version 2.2.0...

For anyone interested, my experience was, if I put the tags on a scenario they are completely ignored, it wasn't user friendly. if I put them on a feature they were applied as deployment item attributes to all scenarios in in the feature. Which would make it impossible to apply to just select scenarios, like for example, as an optimization.

@SabotageAndi

This comment has been minimized.

Show comment
Hide comment
@SabotageAndi

SabotageAndi Aug 4, 2017

Collaborator

@SalamiArmy You are right.
The code for the deploymentitem tag on scenario is missing (https://github.com/techtalk/SpecFlow/blob/master/TechTalk.SpecFlow.Generator/UnitTestProvider/MsTest2010GeneratorProvider.cs#L101).
Please file an issue for this. Thanks!

Collaborator

SabotageAndi commented Aug 4, 2017

@SalamiArmy You are right.
The code for the deploymentitem tag on scenario is missing (https://github.com/techtalk/SpecFlow/blob/master/TechTalk.SpecFlow.Generator/UnitTestProvider/MsTest2010GeneratorProvider.cs#L101).
Please file an issue for this. Thanks!

Autom8edChaos added a commit to Autom8edChaos/SpecFlow that referenced this issue Nov 6, 2017

Update from original (#1)
* update MSBuild.Community.Tasks to latest version via NuGet (#801)

* Regexless stepdef fixes (#786)

* Upgrade FluentAssertions

* Add simple unit test

* Add unit test for parametrized method

* Add unit tests for regexless - 36 failing

* fluent assertion does not allow { and } in the because part

* refine expectations: shortening like "doesn't" should not work automatically

* fix regexless matching issues

* a bit more optimal solution that produces simpler regexes

* Improve param locator

* should not remove keywords from binding culture

* small code improvements

* refine expectations: should not allow whitespace or punctuation in the front of the step text (Given !foo) in order to make the generated regex faster (does not start with rule)

* small refactor

* update changelog, remove wip tags

* add test for issue #715

* Update changelog showing that #301 is also fixed

* add CI NuGet package feed

* Added support for MsTest's [DeploymentItem] attribute with @mstest:DeploymentItem tag (#805)

* Added support for MsTest's [DeploymentItem] attribute with @deploy tag (Issue #803)
* Prefixing new tag with `MsTest:`
* using pascal case @mstest:DeploymentItem
* wrapping nested using blocks with curly brackets

* Change project reader from MSBuild to XML (#837)

* improve tests for project reader
* add tests for new csproj format
* change variable naming
* complete read of classic projects
* refactoring
* mark not used properties as obsolete
* support new project system & refactorings
* use AppDomainIsolatedTask instead of Task to solve file looking issues with MsBuild
* fix typo :-/
* add tests for linked files

* Added display name for theory attribution (#812)

* Added display name for theory attribution
* Fixed incorrect namespace reference to TheoryAttribute (no longer part of extensions)

* Support context parameters on Before/After methods, FeatureContainer (#779)

* Added scenario: Inject FeatureContext into a BeforeFeature hook
* first dummy implementation to make the scenario pass (runtime tests failing)
* Use bindingInstanceResolver to resolve parameters
* make unit tests pass
* Add unit tests for what we have so far
* support for resolving hook parameters from scenario context
* better then step for the scenarios
* fix unit test error
* added failing test for resolving objects from feature container
* refactor ScenarioContext
* Implement FeatureContainer
* move binding culture initialization to FeatureContext
* fix featurecontext resolution from scenario container
* Refactor scenario and feature context and remove displose hack that was necessary to avoid circular disposing loops
* fix unit test failure
* Make InternalContextManager to IObjectContainer reference more explicit
* rename IBindingInstanceResolver to ITestObjectResolver (breaking change for some plugins)

* Wildcard support for project reader (#843)

* Wildcard support for project reader
* fix tests for AppVeyor

* update changelog

* Config file refactoring & Json Config file support (#690)

* split app.config elements to multiple files

* make RuntimeConfiguration nearly immutable

* extract config loading logic to RuntimeConfigurationLoader

* reformating

* add tests for app.config reading

* move ConfigurationTest to separate Namespace

* rename file

* add json tests

* add json.net dependency

* json config file parsing

* add tests for checking which config file is used

* refactoring for tests and added tests

* remove GeneratorConfiguration

* fix dependencies for generator

* fix tests

* fix tests

* move files & fix namespaces

* work on generation config loading

* fix tests and make parsing more robust

* fix and comment test

* small cleanups

* remove ToolLanguage, GeneratorPath and DetectAmbiguousMatches from Config

rename PrintConfigSource to TraceConfigSource

* fix merge issues

* remove file

* add missing json handling

* update changelog

* add Newtonsoft.Json dependency to the NuGet package

* update TestGenerator version

* fix typo in README.md (#853)

* fix VS code behind generation (#855)

* fix redirects
* fix serialization problem with Visual Studio
* fix lineending

* Order sensitive overload for compare to set (#778)

* Add tests
* Refactor TableDifferenceResults to be able to represent order sensitive diff
* make throw tests pass
* refactor message tests to be able to test order sensitive comparison
* fix diff messages for order sensitive
* Replace Tuple with TableDifferenceItem

* Hook with multiple Tags scoped are executed more than once (#848)

* add failing tests
* Fix for #848 Hook with multiple Tags scoped are executed more than once

* making sure that the ordering is preserved (the GroupBy might change the order)

* update changelog for 2.2.0-prerelease20170523

* add GitExtensions configuration file with github and appveyor configuration (#862)

* Added TestThreadContext and exposed it in ContextManager and Steps base class (#875)

* Added TestThreadContext and exposed it in ContextManager and Steps base class

* Upgrade to BoDi v1.3 (#876)

* fix shadow copy test issue
* upgrade BoDi to v1.3
* remove unnecessary BoDi workarounds

* Adds support for xUnit2 ITestOutputHelper #575 (#874)

* Resolves #575 

* added tests for adding support for xUnit2 ITestOutputHelper class

added XUnit2Generator unit tests
added XUnit2Provider specs
updated XUnitExecutionDriver to output results in default (xUnit) xml
output instead of NUnit xml format

* swapped the order of the TestInitialize call and the setting of the _testOutputHelper field

* expose TestAssembly and BindingAssemblies on ITestRunnerManager

* Fix generation from visual studio (#877)

* rename field so that it matches the version of this class from 1.9 (which is used by VS)
* make AppConfig the default value
* add warnings

* Update for 2.2 release

* use FileStream constructor which grants ReadWrite to other processes. (#906)

use FileStream constructor which grants ReadWrite to other processes

techtalk#904

* Added changelog entry for PR (#907)

* correct version number

* Access MSTest's TestContext property via ScenarioContext (#882)

* injected MSTest's TestContext into ScenarioContext

* fixed TestContext property generation for VB.Net

* @MSBuild [DeploymentItem] - added option to provide output directory (#901)

* @MSBuild [DeploymentItem] - added option to provide output directory

* code review

* update changelog after merging PRs #882 & #901

* add tests for Feature/Scenario Hooks with context parameters (#925)

* Issue Template (#924)

* Create issue template

* add SpecFlow+Runner to test runners

* Rename issue to ISSUE_TEMPLATE.md

* Allowed custom XSLT scripts to contain scripts.

* Updated changelog for new addition

* enter release date

* fix changelog after 2.2.1 release

* added link to Stack Overflow repro topic (#942)

* Avoid trying to load empty configuration

* Set ConfigSource of default holder to "Default" instead of "AppConfig"

* Turn off line ending git auto conversion (#953)

* Stop git from automatically converting line endings everytime repo is cloned
* add .vs folder to .gitignore

* Fixing copy link in step definition report (#958)

* Update changelog

* Support for tuples (#951)

* Initial support for Tuples
* Adding nuspec dependency
* Added tupple error when there are too many properties

* add entry for tuple

* Make scenario TestResult public (#963)

* Make scenario TestResult public

* - Rename to ScenarioExecutionStatus
- Moved this to the root of the project
- UndefinedStep in enum
- Edited changelog.txt

* Update changelog.txt

* Single agent for unit tests execution

* Fix incorrect appveyour config

* Try to change test_script to test

* Disable automatic tests

* Provide full path to test assemblies

* Expose configuration var to batch

* Hardcoded configuration as Release

* Use %% accessor for configuration var

* Add hyperlink to discussion group (#965)

Remove ambiguity regarding where to go for questions.
@SalamiArmy

This comment has been minimized.

Show comment
Hide comment
@SalamiArmy

SalamiArmy Nov 17, 2017

How to deploy files with spaces in their name?

How to deploy files with spaces in their name?

@SabotageAndi

This comment has been minimized.

Show comment
Hide comment
@SabotageAndi

SabotageAndi Nov 17, 2017

Collaborator

Gherkin doesn't allow tabs in tagnames, so currently this isn't possible.

Collaborator

SabotageAndi commented Nov 17, 2017

Gherkin doesn't allow tabs in tagnames, so currently this isn't possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment