Skip to content

Commit

Permalink
Feature/add ignore tag (#433)
Browse files Browse the repository at this point in the history
* add .vs to gitignore

* add IgnoreTag Feature

* add ignoreTag parameter in any Runner

* Fix after test with real case

* Implement requests

* Fix whitespace

* Add properties and handling to model and viewmodel

* Insert a row and move all rows down.

* Add label and textbox for exclude tags

* Reorganize UI

* Rename Test Explude Tag "ignore-tag" to "exclude-tag" and add test for no sensitivity
  • Loading branch information
Wil75 authored and dirkrombauts committed Feb 17, 2017
1 parent f69771d commit 3ab6cd6
Show file tree
Hide file tree
Showing 18 changed files with 318 additions and 101 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*.DS_Store

#Visual Studio files
.vs
*.[Oo]bj
*.user
*.aps
Expand Down
7 changes: 7 additions & 0 deletions src/Pickles/Pickles.MSBuild/Pickles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class Pickles : Task

public string EnableComments { get; set; }

public string ExcludeTags { get; set; }

public override bool Execute()
{
try
Expand Down Expand Up @@ -113,6 +115,11 @@ private void CaptureConfiguration(IConfiguration configuration, IFileSystem file
{
configuration.DocumentationFormat = (DocumentationFormat)Enum.Parse(typeof(DocumentationFormat), this.DocumentationFormat, true);
}

if (!string.IsNullOrEmpty(this.ExcludeTags))
{
configuration.ExcludeTags = this.ExcludeTags;
}

bool shouldEnableExperimentalFeatures;

Expand Down
2 changes: 2 additions & 0 deletions src/Pickles/Pickles.ObjectModel/IConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public interface IConfiguration

bool ShouldIncludeExperimentalFeatures { get; }

string ExcludeTags { get; set; }

void AddTestResultFile(FileInfoBase fileInfoBase);

void AddTestResultFiles(IEnumerable<FileInfoBase> fileInfoBases);
Expand Down
8 changes: 8 additions & 0 deletions src/Pickles/Pickles.PowerShell/Pickle_Features.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class Pickle_Features : PSCmdlet
[Parameter(HelpMessage = CommandLineArgumentParser.HelpEnableComments, Mandatory = false)]
public string EnableComments { get; set; }

[Parameter(HelpMessage = CommandLineArgumentParser.HelpExcludeTags, Mandatory = false)]
public string ExcludeTags { get; set; }

protected override void ProcessRecord()
{
var builder = new ContainerBuilder();
Expand Down Expand Up @@ -120,6 +123,11 @@ private void ParseParameters(IConfiguration configuration, IFileSystem fileSyste
configuration.EnableExperimentalFeatures();
}

if (!string.IsNullOrEmpty(this.ExcludeTags))
{
configuration.ExcludeTags = this.ExcludeTags;
}

bool shouldEnableComments;

if (bool.TryParse(this.EnableComments, out shouldEnableComments))
Expand Down
5 changes: 4 additions & 1 deletion src/Pickles/Pickles.Test/BaseFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ protected IContainer Container
if (this.container == null)
{
var builder = new ContainerBuilder();

var configuration = new Configuration() { ExcludeTags = "exclude-tag" };
builder.RegisterAssemblyTypes(typeof(Runner).Assembly);
builder.Register<MockFileSystem>(_ => CreateMockFileSystem()).As<IFileSystem>().SingleInstance();
builder.RegisterModule<PicklesModule>();
builder.RegisterInstance(configuration).As<IConfiguration>().SingleInstance();
this.container = builder.Build();
}

Expand Down Expand Up @@ -88,7 +91,7 @@ protected void AddFakeFolderStructures()
this.AddFakeFolderAndFiles("AcceptanceTest", new[] { "AdvancedFeature.feature", "LevelOne.feature" });
this.AddFakeFolderAndFiles("EmptyFolderTests", new string[0]);

this.AddFakeFolderAndFiles("FeatureCrawlerTests", new[] { "index.md", "LevelOne.feature", "image.png" });
this.AddFakeFolderAndFiles("FeatureCrawlerTests", new[] { "index.md", "LevelOne.feature", "image.png", "LevelOneIgnoredFeature.feature" });
this.AddFakeFolderAndFiles(@"FeatureCrawlerTests\SubLevelOne", new[] { "ignorethisfile.ignore", "LevelOneSublevelOne.feature", "LevelOneSublevelTwo.feature" });
this.AddFakeFolderAndFiles(@"FeatureCrawlerTests\SubLevelOne\SubLevelTwo", new[] { "LevelOneSublevelOneSubLevelTwo.feature" });
this.AddFakeFolderAndFiles(@"FeatureCrawlerTests\SubLevelOne\SubLevelTwo\IgnoreThisDirectory", new[] { "IgnoreThisFile.ignore" });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@exclude-tag
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers

@mytag
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
1 change: 1 addition & 0 deletions src/Pickles/Pickles.Test/Pickles.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
<EmbeddedResource Include="FakeFolderStructures\OrderingTests\B\b-b.feature">
<LastGenOutput>a-b.feature.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="FakeFolderStructures\FeatureCrawlerTests\LevelOneIgnoredFeature.feature" />
<None Include="Resources\test.jpg" />
<EmbeddedResource Include="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
13 changes: 13 additions & 0 deletions src/Pickles/Pickles.Test/WhenParsingCommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -487,5 +487,18 @@ public void ThenSetsLanguageToEnglishByDefault()

Check.That(configuration.Language).IsEqualTo("en");
}

[Test]
public void ThenCanParseExcludeTagsSuccessfully()
{
var args = new[] { @"-excludeTags=exclude-tag" };

var configuration = new Configuration();
var commandLineArgumentParser = new CommandLineArgumentParser(FileSystem);
bool shouldContinue = commandLineArgumentParser.Parse(args, configuration, TextWriter.Null);

Check.That(shouldContinue).IsTrue();
Check.That(configuration.ExcludeTags).IsEqualTo("exclude-tag");
}
}
}
130 changes: 129 additions & 1 deletion src/Pickles/Pickles.Test/WhenParsingFeatureFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Linq;

using Autofac;
using DocumentFormat.OpenXml.Bibliography;
using NFluent;
using NUnit.Framework;
using PicklesDoc.Pickles.Extensions;
Expand Down Expand Up @@ -395,5 +395,133 @@ Then I should see that this thing happens
}



[Test]
public void Then_can_parse_and_ignore_feature_with_tag_in_configuration_ignore_tag()
{
var featureText =
@"# ignore this comment
@feature-tag @exclude-tag
Feature: Test
In order to do something
As a user
I want to run this scenario
@scenario-tag-1 @scenario-tag-2
Scenario: A scenario
Given some feature
When it runs
Then I should see that this thing happens";

var parser = Container.Resolve<FeatureParser>();
var feature = parser.Parse(new StringReader(featureText));
Check.That(feature).IsNull();
}

[Test]
public void Then_can_parse_and_ignore_scenario_with_tag_in_configuration_ignore_tag()
{
var featureText =
@"# ignore this comment
@feature-tag
Feature: Test
In order to do something
As a user
I want to run this scenario
@scenario-tag-1 @scenario-tag-2
Scenario: A scenario
Given some feature
When it runs
Then I should see that this thing happens
@scenario-tag-1 @scenario-tag-2 @exclude-tag
Scenario: B scenario
Given some feature
When it runs
Then I should see that this thing happens
@scenario-tag-1 @scenario-tag-2
Scenario: C scenario
Given some feature
When it runs
Then I should see that this thing happens";

var parser = Container.Resolve<FeatureParser>();
var feature = parser.Parse(new StringReader(featureText));

Check.That(feature.FeatureElements.Count).IsEqualTo(2);
Check.That(feature.FeatureElements.FirstOrDefault(fe => fe.Name == "A scenario")).IsNotNull();
Check.That(feature.FeatureElements.FirstOrDefault(fe => fe.Name == "B scenario")).IsNull();
Check.That(feature.FeatureElements.FirstOrDefault(fe => fe.Name == "C scenario")).IsNotNull();
}

[Test]
public void Then_can_parse_and_ignore_scenario_with_tag_in_configuration_ignore_tag_and_keep_feature()
{
var featureText =
@"# ignore this comment
@feature-tag
Feature: Test
In order to do something
As a user
I want to run this scenario
@scenario-tag-1 @scenario-tag-2 @Exclude-Tag
Scenario: A scenario
Given some feature
When it runs
Then I should see that this thing happens
@scenario-tag-1 @scenario-tag-2 @exclude-tag
Scenario: B scenario
Given some feature
When it runs
Then I should see that this thing happens";

var parser = Container.Resolve<FeatureParser>();
var feature = parser.Parse(new StringReader(featureText));

Check.That(feature).IsNotNull();
Check.That(feature.FeatureElements).IsEmpty();
}

[Test]
public void Then_can_parse_and_ignore_with_with_tag_without_sensitivity()
{

var featureText =
@"# ignore this comment
@feature-tag
Feature: Test
In order to do something
As a user
I want to run this scenario
@scenario-tag-1 @scenario-tag-2 @Exclude-Tag
Scenario: A scenario
Given some feature
When it runs
Then I should see that this thing happens
@scenario-tag-1 @scenario-tag-2 @exclude-tag
Scenario: B scenario
Given some feature
When it runs
Then I should see that this thing happens
@scenario-tag-1 @scenario-tag-2 @ExClUdE-tAg
Scenario: C scenario
Given some feature
When it runs
Then I should see that this thing happens";

var parser = Container.Resolve<FeatureParser>();
var feature = parser.Parse(new StringReader(featureText));

Check.That(feature).IsNotNull();
Check.That(feature.FeatureElements).IsEmpty();
}
}
}

Loading

0 comments on commit 3ab6cd6

Please sign in to comment.