ErraticMotion.Spock 0.0.2

CLI tool for Gherkin based Test Fixtures

Install-Package ErraticMotion.Spock -Version 0.0.2
dotnet add package ErraticMotion.Spock --version 0.0.2
<PackageReference Include="ErraticMotion.Spock" Version="0.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ErraticMotion.Spock --version 0.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Spock

Spock.Net, originally based on the design thinking behind the Java/Groovy tool Spock but has now morphed into something a bit more.

Basic guff is that it's a CLI tool for code generation of Test Fixtures. Very much in Alpha at the moment, so stuff will change.

Will support the 3 main test runners (MSTest, NUNit, and xUnit, use the -t: switch to specify), but working on NUnit for this release, not tested with the other two frameworks, so might get weird results. Will fix any issues with later on.

Current supported command line options.

spock /?
    
SYNTAX
    
[-testrunner(t): <NUnit, MSTest, XUnit>]
  The type of test runner used to run the generated test fixtures
    
[-feature(f): <string>]
  The Gherkin .feature file to be processed
    
[-namespace(n): <string>]
  The fully qualified .NET namespace. If not present will infer from the .feature # namespace: <value>
    
[-directory(d): <string>]
  The fully qualified file system directory to search for Gherkin .feature files.
 
[-help(?): <boolean>]
  displays the syntax usage
    
SAMPLE USAGE
    
  spock /? -or- spock -? -or- spock /
    Display the Spock command line arguments and sample usage
    
  spock -t:MSTest -n:ErraticMotion.Test -f:"c:\projects\customer.feature"
    Creates a MSTest based Test Fixture
    
  spock -testrunner:NUnit -namespace:ErraticMotion.Test -directory:c:\projects\customer\features\

Usage

Given a bit of Gherkin (WithdrawFixedAmounts.feature)

Feature: Withdraw Fixed Amounts

Scenarios: Withdraw fixed amount
  Given I have <Balance> in my account
  When I choose to withdraw a fixed amount of <Withdrawal>
  Then I should <Outcome>
    And the balance of my account should be <Remaining>

  Where: Successful withdrawal
    Can add an optional description in addition to the name for an Examples, Where keyword.
    | Balance | Withdrawal | Outcome           | Remaining |
    | 500D    | 50D        | receive $50 cash  | 450D      |
    | 500     | 100        | receive $100 cash | 400       |

  Where: Attempt to withdraw too much
    | Balance | Withdrawal | Outcome       | Remaining |
    | 100D    | 200D       | see an error  | 100D      |
    | 0       |  50        | see an error  | 0         |

Quick and dirty batch file to set the Path to Spock

set path=".\bin\Debug\

cls

spock -t:NUnit -n:ErraticMotion -g:false -c:Customer -f:WithdrawFixedAmounts.feature

Executing the batch file gives me the C# class (WithdrawFixedAmounts.generated.cs)

// <copyright file="WithdrawFixedAmounts.cs" company="Erratic Motion Ltd">
// Copyright (c) Erratic Motion Ltd. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>

//----------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behaviour and will be lost if
//     the code is regenerated.
// </auto-generated>
//----------------------------------------------------------------------------

// spock -t:NUnit -n:ErraticMotion -f:WithdrawFixedAmounts.feature

namespace ErraticMotion {
using global::ErraticMotion.Test.Tools.Gherkin.Annotations;
using global::NUnit.Framework;
/// <summary>
/// <para>Feature Id: 6c9238f2-2055-4500-88a4-b38ac842beb4</para>
/// <para>Withdraw Fixed Amounts</para>
/// <para></para>
/// </summary>
/// <remarks>
/// <example>
/// <code language="none" title="Gherkin">
/// #language: en
/// #source: C:\Source\spock\Spock\Spock.Test\WithdrawFixedAmounts.feature
/// [Feature]: Withdraw Fixed Amounts
/// 
/// 
/// [Scenarios]: Withdraw fixed amount
///   [Given] I have &amp;lt;Balance&amp;gt; in my account
///   [When] I choose to withdraw a fixed amount of &amp;lt;Withdrawal&amp;gt;
///   [Then] I should &amp;lt;Outcome&amp;gt;
///     [And] the balance of my account should be &amp;lt;Remaining&amp;gt;
///     [Where]: Successful withdrawal
///     Can add an optional description in addition to the name for an Examples, Where keyword.
///           (Balance,Withdrawal,Outcome,Remaining)
///           (500D,50D,receive $50 cash,450D)
///           (500,100,receive $100 cash,400)
///     [Where]: Attempt to withdraw too much
///           (Balance,Withdrawal,Outcome,Remaining)
///           (100D,200D,see an error,100D)
///           (0,50,see an error,0)
/// 
/// 
/// </code>
/// </example>
/// </remarks>
[FeatureId("6c9238f2-2055-4500-88a4-b38ac842beb4")]
[Feature("")]
[GeneratedFromFeature]
[TestFixture]
[Category("Customer")]
public partial class WithdrawFixedAmounts
{
partial void WhereWithdrawFixedAmount(double Balance, double Withdrawal, string Outcome, double Remaining);
partial void GivenIHaveBalanceInMyAccount();
partial void WhenIChooseToWithdrawAFixedAmountOfWithdrawal();
partial void ThenIShouldOutcome();
partial void AndTheBalanceOfMyAccountShouldBeRemaining();

private void OnWithdrawFixedAmount(double Balance, double Withdrawal, string Outcome, double Remaining)
{
   WhereWithdrawFixedAmount(Balance, Withdrawal, Outcome, Remaining);
   GivenIHaveBalanceInMyAccount();
   WhenIChooseToWithdrawAFixedAmountOfWithdrawal();
   ThenIShouldOutcome();
   AndTheBalanceOfMyAccountShouldBeRemaining();
}

/// <summary>
/// <para>Scenario Id: fe58a24e-4918-421c-ad82-499e8812d794</para>
/// <para>Withdraw fixed amount</para>
/// <para></para>
/// </summary>
/// <remarks>
/// <example>
/// <code language="none" title="Gherkin">
/// [Scenarios]: Withdraw fixed amount
///   [Given] I have &amp;lt;Balance&amp;gt; in my account
///   [When] I choose to withdraw a fixed amount of &amp;lt;Withdrawal&amp;gt;
///   [Then] I should &amp;lt;Outcome&amp;gt;
///     [And] the balance of my account should be &amp;lt;Remaining&amp;gt;
///     [Where]: Successful withdrawal
///     Can add an optional description in addition to the name for an Examples, Where keyword.
///           (Balance,Withdrawal,Outcome,Remaining)
///           (500D,50D,receive $50 cash,450D)
///           (500,100,receive $100 cash,400)
///     [Where]: Attempt to withdraw too much
///           (Balance,Withdrawal,Outcome,Remaining)
///           (100D,200D,see an error,100D)
///           (0,50,see an error,0)
/// </code>
/// </example>
/// </remarks>
[ScenarioId("fe58a24e-4918-421c-ad82-499e8812d794")]
[System.CLSCompliant(false)]
[TestCase(500, 50, "receive $50 cash", 450)]
[TestCase(500, 100, "receive $100 cash", 400)]
[TestCase(100, 200, "see an error", 100)]
[TestCase(0, 50, "see an error", 0)]
public void WithdrawFixedAmount(double Balance, double Withdrawal, string Outcome, double Remaining)
{
   OnWithdrawFixedAmount(Balance, Withdrawal, Outcome, Remaining);
}
}
}

Spock

Spock.Net, originally based on the design thinking behind the Java/Groovy tool Spock but has now morphed into something a bit more.

Basic guff is that it's a CLI tool for code generation of Test Fixtures. Very much in Alpha at the moment, so stuff will change.

Will support the 3 main test runners (MSTest, NUNit, and xUnit, use the -t: switch to specify), but working on NUnit for this release, not tested with the other two frameworks, so might get weird results. Will fix any issues with later on.

Current supported command line options.

spock /?
    
SYNTAX
    
[-testrunner(t): <NUnit, MSTest, XUnit>]
  The type of test runner used to run the generated test fixtures
    
[-feature(f): <string>]
  The Gherkin .feature file to be processed
    
[-namespace(n): <string>]
  The fully qualified .NET namespace. If not present will infer from the .feature # namespace: <value>
    
[-directory(d): <string>]
  The fully qualified file system directory to search for Gherkin .feature files.
 
[-help(?): <boolean>]
  displays the syntax usage
    
SAMPLE USAGE
    
  spock /? -or- spock -? -or- spock /
    Display the Spock command line arguments and sample usage
    
  spock -t:MSTest -n:ErraticMotion.Test -f:"c:\projects\customer.feature"
    Creates a MSTest based Test Fixture
    
  spock -testrunner:NUnit -namespace:ErraticMotion.Test -directory:c:\projects\customer\features\

Usage

Given a bit of Gherkin (WithdrawFixedAmounts.feature)

Feature: Withdraw Fixed Amounts

Scenarios: Withdraw fixed amount
  Given I have <Balance> in my account
  When I choose to withdraw a fixed amount of <Withdrawal>
  Then I should <Outcome>
    And the balance of my account should be <Remaining>

  Where: Successful withdrawal
    Can add an optional description in addition to the name for an Examples, Where keyword.
    | Balance | Withdrawal | Outcome           | Remaining |
    | 500D    | 50D        | receive $50 cash  | 450D      |
    | 500     | 100        | receive $100 cash | 400       |

  Where: Attempt to withdraw too much
    | Balance | Withdrawal | Outcome       | Remaining |
    | 100D    | 200D       | see an error  | 100D      |
    | 0       |  50        | see an error  | 0         |

Quick and dirty batch file to set the Path to Spock

set path=".\bin\Debug\

cls

spock -t:NUnit -n:ErraticMotion -g:false -c:Customer -f:WithdrawFixedAmounts.feature

Executing the batch file gives me the C# class (WithdrawFixedAmounts.generated.cs)

// <copyright file="WithdrawFixedAmounts.cs" company="Erratic Motion Ltd">
// Copyright (c) Erratic Motion Ltd. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// </copyright>

//----------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behaviour and will be lost if
//     the code is regenerated.
// </auto-generated>
//----------------------------------------------------------------------------

// spock -t:NUnit -n:ErraticMotion -f:WithdrawFixedAmounts.feature

namespace ErraticMotion {
using global::ErraticMotion.Test.Tools.Gherkin.Annotations;
using global::NUnit.Framework;
/// <summary>
/// <para>Feature Id: 6c9238f2-2055-4500-88a4-b38ac842beb4</para>
/// <para>Withdraw Fixed Amounts</para>
/// <para></para>
/// </summary>
/// <remarks>
/// <example>
/// <code language="none" title="Gherkin">
/// #language: en
/// #source: C:\Source\spock\Spock\Spock.Test\WithdrawFixedAmounts.feature
/// [Feature]: Withdraw Fixed Amounts
/// 
/// 
/// [Scenarios]: Withdraw fixed amount
///   [Given] I have &amp;lt;Balance&amp;gt; in my account
///   [When] I choose to withdraw a fixed amount of &amp;lt;Withdrawal&amp;gt;
///   [Then] I should &amp;lt;Outcome&amp;gt;
///     [And] the balance of my account should be &amp;lt;Remaining&amp;gt;
///     [Where]: Successful withdrawal
///     Can add an optional description in addition to the name for an Examples, Where keyword.
///           (Balance,Withdrawal,Outcome,Remaining)
///           (500D,50D,receive $50 cash,450D)
///           (500,100,receive $100 cash,400)
///     [Where]: Attempt to withdraw too much
///           (Balance,Withdrawal,Outcome,Remaining)
///           (100D,200D,see an error,100D)
///           (0,50,see an error,0)
/// 
/// 
/// </code>
/// </example>
/// </remarks>
[FeatureId("6c9238f2-2055-4500-88a4-b38ac842beb4")]
[Feature("")]
[GeneratedFromFeature]
[TestFixture]
[Category("Customer")]
public partial class WithdrawFixedAmounts
{
partial void WhereWithdrawFixedAmount(double Balance, double Withdrawal, string Outcome, double Remaining);
partial void GivenIHaveBalanceInMyAccount();
partial void WhenIChooseToWithdrawAFixedAmountOfWithdrawal();
partial void ThenIShouldOutcome();
partial void AndTheBalanceOfMyAccountShouldBeRemaining();

private void OnWithdrawFixedAmount(double Balance, double Withdrawal, string Outcome, double Remaining)
{
   WhereWithdrawFixedAmount(Balance, Withdrawal, Outcome, Remaining);
   GivenIHaveBalanceInMyAccount();
   WhenIChooseToWithdrawAFixedAmountOfWithdrawal();
   ThenIShouldOutcome();
   AndTheBalanceOfMyAccountShouldBeRemaining();
}

/// <summary>
/// <para>Scenario Id: fe58a24e-4918-421c-ad82-499e8812d794</para>
/// <para>Withdraw fixed amount</para>
/// <para></para>
/// </summary>
/// <remarks>
/// <example>
/// <code language="none" title="Gherkin">
/// [Scenarios]: Withdraw fixed amount
///   [Given] I have &amp;lt;Balance&amp;gt; in my account
///   [When] I choose to withdraw a fixed amount of &amp;lt;Withdrawal&amp;gt;
///   [Then] I should &amp;lt;Outcome&amp;gt;
///     [And] the balance of my account should be &amp;lt;Remaining&amp;gt;
///     [Where]: Successful withdrawal
///     Can add an optional description in addition to the name for an Examples, Where keyword.
///           (Balance,Withdrawal,Outcome,Remaining)
///           (500D,50D,receive $50 cash,450D)
///           (500,100,receive $100 cash,400)
///     [Where]: Attempt to withdraw too much
///           (Balance,Withdrawal,Outcome,Remaining)
///           (100D,200D,see an error,100D)
///           (0,50,see an error,0)
/// </code>
/// </example>
/// </remarks>
[ScenarioId("fe58a24e-4918-421c-ad82-499e8812d794")]
[System.CLSCompliant(false)]
[TestCase(500, 50, "receive $50 cash", 450)]
[TestCase(500, 100, "receive $100 cash", 400)]
[TestCase(100, 200, "see an error", 100)]
[TestCase(0, 50, "see an error", 0)]
public void WithdrawFixedAmount(double Balance, double Withdrawal, string Outcome, double Remaining)
{
   OnWithdrawFixedAmount(Balance, Withdrawal, Outcome, Remaining);
}
}
}

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.0.2 141 1/19/2019
0.0.1-alpha 230 1/26/2018