Exemple #1
0
def Generate(parsed, settings):
    scenarios = parsed[0]
    feature = parsed[1]
    featureName = common.FeatureName(feature, settings["cases"]["class"])

    printer = PrintScenario()
    featureDesc = printer.FeatureDesc(feature)

    concat = """
namespace [[rootnamespace]][[namespace]].Scenarios
{
"""[1:]

    namespace = common.FeatureName(feature, settings["cases"]["namespace"])
    concat = concat.replace("[[rootnamespace]]", settings["rootnamespace"])
    concat = concat.replace("[[namespace]]", namespace)

    for scenario in scenarios:
        buffer = """
  /// <summary>
  /// Test class scenario
  /// </summary>
  public class [[featureName]]
  {
    /// <summary>
    /// Constructor
    /// </summary>
    public [[featureName]]()
    {
[[documentation]]
    }

[[steps]]
  }

"""[1:]

        buffer = buffer.replace(
            "[[featureName]]",
            common.Tokenise(scenario.lines, settings["cases"]["class"]))
        documentation = printer.Documentation(scenario, featureDesc, settings)
        buffer = buffer.replace("[[documentation]]", documentation)
        buffer = buffer.replace("[[steps]]", printer.Steps(scenario, settings))
        concat += buffer

    concat = concat[:-2] + """
}
"""
    return concat
Exemple #2
0
def Generate(parsed, settings):
    scenarios = parsed[0]
    feature = parsed[1]

    buffer = """
import unittest
from [[scenarios file]] import *


class [[className]](unittest.TestCase):
    [[comment]]

[[TestBody]]


if __name__ == '__main__':
    unittest.main()
"""[1:]

    className = common.FeatureName(feature, settings["cases"]["class"])
    buffer = buffer.replace("[[className]]", className)
    buffer = buffer.replace("[[comment]]", '"""Gherkin DSL feature"""')
    buffer = buffer.replace("[[scenarios file]]", settings["scenarios file"])

    py = pyutils.Python(settings)
    testBody = py.TestBody(scenarios, settings)
    buffer = buffer.replace("[[TestBody]]", testBody)

    return buffer
Exemple #3
0
def Generate(parsed, settings):
    scenarios = parsed[0]
    feature = parsed[1]
    buffer = """
namespace [[rootnamespace]][[namespace]]
{
  using NUnit.Framework;

  /// <summary>
  /// Gherkin DSL feature
  /// </summary>
  [TestFixture]
  public class [[className]]
  {
[[TestBody]]
  }
}
"""[1:]

    namespace = common.FeatureName(feature, settings["cases"]["namespace"])
    buffer = buffer.replace("[[rootnamespace]]", settings["rootnamespace"])
    buffer = buffer.replace("[[namespace]]", namespace)

    # Print the class
    className = common.Tokenise("Feature", settings["cases"]["class"])
    buffer = buffer.replace("[[className]]", className)

    cs = csutils.CSharp(settings, "Test")
    testBody = cs.TestBody(scenarios, settings)
    buffer = buffer.replace("[[TestBody]]", testBody)

    return buffer
Exemple #4
0
def Generate(parsed, settings):
    scenarios = parsed[0]
    feature = parsed[1]
    buffer = """
Imports NUnit.Framework

Namespace [[rootnamespace]][[namespace]]

  ' <summary>
  ' Gherkin DSL feature
  ' </summary>
  <TestFixture>
  Public Class [[className]]
[[TestBody]]
  End Class
End Namespace
"""[1:]

    namespace = common.FeatureName(feature, settings["cases"]["namespace"])
    buffer = buffer.replace("[[rootnamespace]]", settings["rootnamespace"])
    buffer = buffer.replace("[[namespace]]", namespace)

    # Print the class
    className = common.Tokenise("Feature", settings["cases"]["class"])
    buffer = buffer.replace("[[className]]", className)

    vb = vbutils.VBasic(settings, "Test")
    testBody = vb.TestBody(scenarios, settings)
    buffer = buffer.replace("[[TestBody]]", testBody)

    return buffer
Exemple #5
0
def Generate(parsed, settings):
    scenarios = parsed[0]
    feature = parsed[1]
    featureName = common.FeatureName(feature, settings["cases"]["class"])

    printer = PrintScenario()
    featureDesc = printer.FeatureDesc(feature)

    concat = """
Namespace [[rootnamespace]][[namespace]].Scenarios
"""[1:]

    namespace = common.FeatureName(feature, settings["cases"]["namespace"])
    concat = concat.replace("[[rootnamespace]]", settings["rootnamespace"])
    concat = concat.replace("[[namespace]]", namespace)

    for scenario in scenarios:
        buffer = """
  ' <summary>
  ' Test class scenario
  ' </summary>
  Public Class [[featureName]]
    ' <summary>
    ' Constructor
    ' </summary>
    Public Sub New()
[[documentation]]
    End Sub

[[steps]]
  End Class

"""[1:]

        buffer = buffer.replace(
            "[[featureName]]",
            common.Tokenise(scenario.lines, settings["cases"]["class"]))
        documentation = printer.Documentation(scenario, featureDesc, settings)
        buffer = buffer.replace("[[documentation]]", documentation)
        buffer = buffer.replace("[[steps]]", printer.Steps(scenario, settings))
        concat += buffer

    concat = concat[:-2] + """
End Namespace
"""
    return concat
Exemple #6
0
def Generate(parsed, settings):
    scenarios = parsed[0]
    feature = parsed[1]
    featureName = common.FeatureName(feature, settings["cases"]["namespace"])

    printer = PrintScenario()
    featureDesc = printer.FeatureDesc(feature)

    concat = """
#pragma once

// Local headers

// Third party headers

// Standard library headers
#include <iostream>
#include <string>

namespace [[fullnamespace]]
{
"""[1:]

    namespace = common.Tokenise(featureName, settings["cases"]["namespace"])
    namespace = cpputils.NameSpace(settings, namespace + "::Scenarios")
    concat = concat.replace("[[fullnamespace]]", namespace.Begin())

    for scenario in scenarios:
        buffer = """
  /// Test class scenario
  class [[featureName]]
  {
  public:
    /// Constructor
    [[featureName]]()
    {
[[documentation]]
    }

[[steps]]
  };

"""[1:]

        buffer = buffer.replace(
            "[[featureName]]",
            common.Tokenise(scenario.lines, settings["cases"]["class"]))
        documentation = printer.Documentation(scenario, featureDesc, settings)
        buffer = buffer.replace("[[documentation]]", documentation)
        buffer = buffer.replace("[[steps]]", printer.Steps(scenario, settings))
        concat += buffer

    concat = concat[:-2] + """
[[endnamespace]]
""".replace("[[endnamespace]]", namespace.End())
    return concat
Exemple #7
0
def Generate(parsed, settings):
    scenarios = parsed[0]
    feature = parsed[1]
    buffer = """
// Other bespoke headers
#include "[[scenarios file]]"

// Third party headers
#include "CppUnitTest.h"

namespace [[fullnamespace]]
{
  TEST_CLASS([[className]])
  {
[[TestBody]]
  };
[[endnamespace]]
"""[1:]

    buffer = buffer.replace("[[scenarios file]]", settings["scenarios file"])

    namespace = common.FeatureName(feature, settings["cases"]["namespace"])
    namespace = cpputils.NameSpace(settings, namespace)
    buffer = buffer.replace("[[fullnamespace]]", namespace.Begin())
    buffer = buffer.replace("[[endnamespace]]", namespace.End())

    # Print the class
    featureName = common.FeatureName(feature, settings["cases"]["class"])
    buffer = buffer.replace("[[featureName]]", featureName)
    className = common.Tokenise("Feature", settings["cases"]["class"])
    buffer = buffer.replace("[[className]]", className)

    decl = "    static void {0}({1})\n"
    testdecl = "    TEST_METHOD({0})\n"
    cpp = cpputils.Cpp(settings, decl, testdecl, "    ")
    testBody = cpp.TestBody(scenarios, settings)
    buffer = buffer.replace("[[TestBody]]", testBody)

    return buffer
Exemple #8
0
def Generate(parsed, settings):
    scenarios = parsed[0]
    feature = parsed[1]
    featureName = common.FeatureName(feature, settings["cases"]["namespace"])
    namespace = common.Tokenise(featureName, settings["cases"]["namespace"])

    buffer = """
// Other bespoke headers
#include "[[scenarios file]]"

// Third party headers
#include "gtest/gtest.h"

namespace [[fullnamespace]]
{
  class TestFixture : public ::testing::Test
  {
  protected:
    void SetUp() override
    {
    }

    void TearDown() override
    {
    }
  };

[[TestBody]]
[[endnamespace]]
"""[1:]

    buffer = buffer.replace("[[scenarios file]]", settings["scenarios file"])

    ns = cpputils.NameSpace(settings, namespace)
    buffer = buffer.replace("[[fullnamespace]]", ns.Begin())
    buffer = buffer.replace("[[endnamespace]]", ns.End())

    decl = "  static void {0}({1})\n"
    testdecl = "  TEST_F(TestFixture, {0})\n"
    cpp = cpputils.Cpp(settings, decl, testdecl, "  ")
    testBody = cpp.TestBody(scenarios, settings)
    buffer = buffer.replace("[[TestBody]]", testBody)

    return buffer