forked from x97mdr/pickles
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Cucumber JSON Documentation Builder (#413)
* Adding Cucumber JSON as possible export format * Version * fixing the tests * Fixing unit tests * Separated Cucumber Documentation as separate project * Fixing Build Pipeline * Adding missed build dependency steps * resolved the namespace issues that was preventing the build from completing successfully * Addressing code review comments * adding cucumber output format
- Loading branch information
1 parent
ddd1f08
commit 5769fa5
Showing
33 changed files
with
1,123 additions
and
7 deletions.
There are no files selected for viewing
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
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
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
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
11 changes: 11 additions & 0 deletions
11
src/Pickles/Pickles.DocumentationBuilders.Cucumber.UnitTests/App.config
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,11 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<configSections> | ||
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow"/> | ||
</configSections> | ||
<specFlow> | ||
<!-- For additional details on SpecFlow configuration options see http://go.specflow.org/doc-config --> | ||
<unitTestProvider name="NUnit" /> | ||
|
||
</specFlow> | ||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration> |
76 changes: 76 additions & 0 deletions
76
...ckles/Pickles.DocumentationBuilders.Cucumber.UnitTests/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,76 @@ | ||
// -------------------------------------------------------------------------------------------------------------------- | ||
// <copyright file="StepDefinitions.cs" company="PicklesDoc"> | ||
// Copyright 2017 Dmitry Grekov | ||
// 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.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using TechTalk.SpecFlow; | ||
using PicklesDoc.Pickles.DocumentationBuilders.Cucumber; | ||
using PicklesDoc.Pickles.Test; | ||
using PicklesDoc.Pickles.DataStructures; | ||
using PicklesDoc.Pickles; | ||
using System.IO; | ||
using PicklesDoc.Pickles.DirectoryCrawler; | ||
using Autofac; | ||
using NFluent; | ||
|
||
namespace Pickles.DocumentationBuilders.Cucumber.UnitTests.AutomationLayer | ||
{ | ||
[Binding] | ||
[Scope(Tag = "cucumber")] | ||
public sealed class StepDefinitions : BaseFixture /* God object antipattern */ | ||
{ | ||
private Tree 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 Tree(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"); | ||
|
||
//standardize newlines across various environments | ||
actualResult = actualResult.Replace("\r\n", "\n"); | ||
expectedResult = expectedResult.Replace("\r\n", "\n"); | ||
Check.That(actualResult).Contains(expectedResult); | ||
} | ||
} | ||
} |
165 changes: 165 additions & 0 deletions
165
src/Pickles/Pickles.DocumentationBuilders.Cucumber.UnitTests/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.