SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.25k stars 754 forks source link

Is there a date(time) format supported for code generation? #1957

Closed 304NotModified closed 4 years ago

304NotModified commented 4 years ago

SpecFlow Version:

Used Test Runner

Version number:

Project Format of the SpecFlow project

.feature.cs files are generated using

Visual Studio Version

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

Are the latest Visual Studio updates installed?

.NET Framework:

Test Execution Method:

<SpecFlow> Section in app.config or content of specflow.json

none

Repro Project

Issue Description

Is there a date format in the scenario which is recognized as date?

  1. Write scenario with date(time)
  2. Generate code
  3. Expected: regex with and methods with datetime
  4. Current result: regels and method with strings/ints

Steps to Reproduce

Tested these examples:

Scenario Outline: dates
    Given my proccess start on 12-12-2019
    And my other proccess start on 2019-12-12
    And my last proccess start on 2019/12/12

Scenario Outline: dates with quotes
    Given my proccess start on '12-12-2019'
    And my other proccess start on '2019-12-12'
    And my last proccess start on '2019/12/12'

Scenario Outline: datetimes
    Given my proccess start on 12-12-2019 12:00
    And my other proccess start on 2019-12-12 12:00
    And my last proccess start on 2019/12/12 12:00

And that will give:

        [Given(@"my proccess start on (.*)(.*)")]
        public void GivenMyProccessStartOn(string p0, int p1)
        {
            ScenarioContext.Current.Pending();
        }

        [Given(@"my other proccess start on (.*)(.*)")]
        public void GivenMyOtherProccessStartOn(string p0, int p1)
        {
            ScenarioContext.Current.Pending();
        }

        [Given(@"my last proccess start on (.*)/(.*)")]
        public void GivenMyLastProccessStartOn(string p0, int p1)
        {
            ScenarioContext.Current.Pending();
        }

        [Given(@"my proccess start on '(.*)'")]
        public void GivenMyProccessStartOn(string p0)
        {
            ScenarioContext.Current.Pending();
        }

        [Given(@"my other proccess start on '(.*)'")]
        public void GivenMyOtherProccessStartOn(string p0)
        {
            ScenarioContext.Current.Pending();
        }

        [Given(@"my last proccess start on '(.*)'")]
        public void GivenMyLastProccessStartOn(string p0)
        {
            ScenarioContext.Current.Pending();
        }

        [Given(@"my proccess start on (.*)(.*):(.*)")]
        public void GivenMyProccessStartOn(string p0, string p1, int p2)
        {
            ScenarioContext.Current.Pending();
        }

        [Given(@"my other proccess start on (.*)(.*):(.*)")]
        public void GivenMyOtherProccessStartOn(string p0, string p1, int p2)
        {
            ScenarioContext.Current.Pending();
        }

        [Given(@"my last proccess start on (.*)/(.*):(.*)")]
        public void GivenMyLastProccessStartOn(string p0, string p1, int p2)
        {
            ScenarioContext.Current.Pending();
        }

So int/string and no datetimes

304NotModified commented 4 years ago

I think the answer is currently not :)

I've made a PR for date support, some guidance would be great. -> https://github.com/SpecFlowOSS/SpecFlow/pull/1958

If merged, I could also made a PR for datetimes.

SabotageAndi commented 4 years ago

Thanks for the PR. But at the moment it wouldn't change anything. AFAIK the SpecFlow VS extension is calling the code in the used SpecFlow 1.9 in the extension and not the version that is used in the project. And updating the SpecFlow version in the VS Extension is a lot of work that we didn't do in the last years.

We started the work on it (https://github.com/SpecFlowOSS/SpecFlow.VisualStudio/tree/update_specflow_version) but never finished it.

304NotModified commented 4 years ago

That's a bummer!

Could we still merge the PR? I think it's good and that's another reason to get the VS extension up-to-date. Maybe I have time to check it then.

SabotageAndi commented 4 years ago

The PR is merged @304NotModified. As written there, this PR increased my motivation to find a solution for the Visual Studio Extension and its old SpecFlow version.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.