Skip to content

Commit

Permalink
Merge pull request #1 from armsteadj1/develop
Browse files Browse the repository at this point in the history
merging in tests
  • Loading branch information
dgrekov authored Jan 20, 2017
2 parents 6e9ad65 + 290491f commit e4aa6c5
Show file tree
Hide file tree
Showing 9 changed files with 503 additions and 46 deletions.
Empty file added index.html
Empty file.
2 changes: 1 addition & 1 deletion src/Pickles/.vs/config/applicationhost.config
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</site>
<site name="Pickles.BaseDhtmlFiles" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\src\pickles\src\Pickles\Pickles.BaseDhtmlFiles" />
<virtualDirectory path="/" physicalPath="C:\Users\jarmstead\projects\pickles\src\Pickles\Pickles.BaseDhtmlFiles" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:52000:localhost" />
Expand Down
6 changes: 3 additions & 3 deletions src/Pickles/Pickles.ObjectModel/ObjectModel/Feature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ public Feature()

public string Description { get; set; }

public List<IFeatureElement> FeatureElements { get; }
public List<IFeatureElement> FeatureElements { get; private set; }

public List<Comment> Comments { get; }
public List<Comment> Comments { get; private set; }

public Scenario Background { get; private set; }

public TestResult Result { get; set; }

public List<string> Tags { get; }
public List<string> Tags { get; private set; }

public void AddTag(string tag)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="StepDefinitions.cs" company="PicklesDoc">
// Copyright 2011 Jeffrey Cameron
// Copyright 2012-present PicklesDoc team and community contributors
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.IO;
using Autofac;
using NFluent;
using NGenerics.DataStructures.Trees;
using PicklesDoc.Pickles.DirectoryCrawler;
using PicklesDoc.Pickles.DocumentationBuilders.Cucumber;
using PicklesDoc.Pickles.DocumentationBuilders.JSON;
using TechTalk.SpecFlow;

namespace PicklesDoc.Pickles.Test.DocumentationBuilders.Cucumber.AutomationLayer
{
[Binding]
[Scope(Tag = "cucumber")]
public sealed class StepDefinitions : BaseFixture /* God object antipattern */
{
private GeneralTree<INode> nodes;

[Given("I have this feature description")]
public void IHaveThisFeatureDescription(string featureDescription)
{
var configuration = this.Configuration;
FeatureParser parser = new FeatureParser(this.FileSystem, configuration);

var feature = parser.Parse(new StringReader(featureDescription));

this.nodes = new GeneralTree<INode>(new FeatureNode(this.FileSystem.DirectoryInfo.FromDirectoryName(@"c:\output\"), string.Empty, feature));
}

[When(@"I generate the documentation")]
public void WhenIGenerateTheJsonDocumentation()
{
var configuration = this.Configuration;
configuration.OutputFolder = this.FileSystem.DirectoryInfo.FromDirectoryName(@"c:\output\");
var jsonDocumentationBuilder = this.Container.Resolve<CucumberDocumentationBuilder>();

jsonDocumentationBuilder.Build(this.nodes);
}

[Then("the JSON file should contain")]
public void ThenTheResultShouldBe(string expectedResult)
{
var actualResult = this.FileSystem.File.ReadAllText(@"c:\output\cucumberResult.json");

Console.WriteLine("----------------------------------------------------");
Console.WriteLine(actualResult);
actualResult = actualResult.Replace("{", "{{").Replace("}", "}}");
expectedResult = expectedResult.Replace("{", "{{").Replace("}", "}}");
Check.That(actualResult).Contains(expectedResult);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
Feature: Formatting A Feature

@cucumber
Scenario: A simple feature

Given I have this feature description
"""
Feature: Clearing Screen
In order to restart a new set of calculations
As a math idiot
I want to be able to clear the screen
@workflow @slow
Scenario: Clear the screen
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press C
Then the screen should be empty
"""
When I generate the documentation
Then the JSON file should contain
"""
[
{
"keyword": "Feature",
"name": "Clearing Screen",
"tags": [],
"line": 1,
"elements": [
{
"keyword": "Scenario",
"name": "Clear the screen",
"line": 7,
"type": "scenario",
"tags": [
{
"name": "@workflow"
},
{
"name": "@slow"
}
],
"steps": [
{
"keyword": "Given",
"name": "I have entered 50 into the calculator",
"line": 8,
"result": {
"status": "inconclusive",
"duration": 1
}
},
{
"keyword": "And",
"name": "I have entered 70 into the calculator",
"line": 9,
"result": {
"status": "inconclusive",
"duration": 1
}
},
{
"keyword": "When",
"name": "I press C",
"line": 10,
"result": {
"status": "inconclusive",
"duration": 1
}
},
{
"keyword": "Then",
"name": "the screen should be empty",
"line": 11,
"result": {
"status": "inconclusive",
"duration": 1
}
}
"""

@cucumber
Scenario: A feature with a table

Given I have this feature description
"""
Feature: Interactive DHTML View
In order to increase stakeholder engagement with pickled specs
As a SpecFlow evangelist
I want to adjust the level of detail in the DHTML view to suit my audience
So that I do not overwhelm them.
Scenario: Scenario with large data table
Given a feature with a large table of data:
| heading | page # |
| Chapter 1 | 1 |
| Chapter 2 | 5 |
| Chapter 3 | 10 |
| Chapter 4 | 15 |
| Chapter 5 | 20 |
| Chapter 6 | 25 |
| Chapter 7 | 30 |
| Chapter 8 | 35 |
| Chapter 9 | 40 |
| Chapter 10 | 45 |
| Chapter 11 | 50 |
| Chapter 12 | 55 |
| Chapter 13 | 60 |
| Chapter 14 | 65 |
| Chapter 15 | 70 |
| Chapter 16 | 75 |
| Chapter 17 | 80 |
| Chapter 18 | 85 |
| Chapter 19 | 90 |
| Chapter 20 | 95 |
| Chapter 21 | 100 |
| Chapter 22 | 105 |
When I click on the table heading
Then the table body should collapse
"""
When I generate the documentation
Then the JSON file should contain
"""
[
{
"keyword": "Feature",
"name": "Interactive DHTML View",
"tags": [],
"line": 1,
"elements": [
{
"keyword": "Scenario",
"name": "Scenario with large data table",
"line": 7,
"type": "scenario",
"tags": [],
"steps": [
{
"keyword": "Given",
"name": "a feature with a large table of data:",
"line": 8,
"result": {
"status": "inconclusive",
"duration": 1
}
},
{
"keyword": "When",
"name": "I click on the table heading",
"line": 32,
"result": {
"status": "inconclusive",
"duration": 1
}
},
{
"keyword": "Then",
"name": "the table body should collapse",
"line": 33,
"result": {
"status": "inconclusive",
"duration": 1
}
}
"""
Loading

0 comments on commit e4aa6c5

Please sign in to comment.