forked from picklesdoc/pickles
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from armsteadj1/develop
merging in tests
- Loading branch information
Showing
9 changed files
with
503 additions
and
46 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
src/Pickles/Pickles.Test/DocumentationBuilders/Cucumber/AutomationLayer/StepDefinitions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
165 changes: 165 additions & 0 deletions
165
src/Pickles/Pickles.Test/DocumentationBuilders/Cucumber/FormattingAFeature.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
""" |
Oops, something went wrong.