Discussion:
[specflow] Getting scenario outline examples
Matthew Chan
2015-10-01 07:01:08 UTC
Permalink
Hi,

I currently want to return the rows for the Examples for Scenario Outlines
and get the size of the rows, however I am unable to do this as when
SpecRun reads the feature files, it automatically converts scenario outline
examples into individual scenarios for a custom report we want to create
which requires this information.

ScenarioContext.Current.ScenarioInfo does not give me this capability.

When faced with the same issue in JAVA, we implemented gherkin.formatter
into a custom class and invoked it in the RunCukesTest class with plugins =
{"my.package.customreport"}

However I'm not sure how the same can be done in .Net SpecRun after
importing the gherkin.dll.

Could anybody please shed some light on this or give an alternate solution?

Thanks!
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jan Regent
2015-10-03 15:25:39 UTC
Permalink
I have this solution

Scenario Outline: some title
Given I have ...
When I read ... with '<api_key>'
Then ...
Examples:
| api_key |
| @@app.config=api_key_full |
| @@app.config=api_key_limited |


In THEN step I have
reportHelper.Report_Pass(ScenarioContext.Current.ScenarioInfo.Title
+ " - " + restHelper.Api_key);

where restHelper.Api_key is value from WHEN '<api_key>'

It gives different names scenario in the report

Enjoy JRE
Post by Matthew Chan
Hi,
I currently want to return the rows for the Examples for Scenario Outlines
and get the size of the rows, however I am unable to do this as when
SpecRun reads the feature files, it automatically converts scenario outline
examples into individual scenarios for a custom report we want to create
which requires this information.
ScenarioContext.Current.ScenarioInfo does not give me this capability.
When faced with the same issue in JAVA, we implemented gherkin.formatter
into a custom class and invoked it in the RunCukesTest class with plugins =
{"my.package.customreport"}
However I'm not sure how the same can be done in .Net SpecRun after
importing the gherkin.dll.
Could anybody please shed some light on this or give an alternate solution?
Thanks!
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthew Chan
2015-10-04 12:36:46 UTC
Permalink
Hi Jan,

Thank you for your reply, however this doesn't work for me because I need
this to work for ALL steps and this also doesn't give me the number of
examples and iteration number.

Regards,
Matt
Post by Jan Regent
I have this solution
Scenario Outline: some title
Given I have ...
When I read ... with '<api_key>'
Then ...
| api_key |
In THEN step I have
reportHelper.Report_Pass(ScenarioContext.Current.ScenarioInfo.Title
+ " - " + restHelper.Api_key);
where restHelper.Api_key is value from WHEN '<api_key>'
It gives different names scenario in the report
Enjoy JRE
Post by Matthew Chan
Hi,
I currently want to return the rows for the Examples for Scenario
Outlines and get the size of the rows, however I am unable to do this as
when SpecRun reads the feature files, it automatically converts scenario
outline examples into individual scenarios for a custom report we want to
create which requires this information.
ScenarioContext.Current.ScenarioInfo does not give me this capability.
When faced with the same issue in JAVA, we implemented gherkin.formatter
into a custom class and invoked it in the RunCukesTest class with plugins =
{"my.package.customreport"}
However I'm not sure how the same can be done in .Net SpecRun after
importing the gherkin.dll.
Could anybody please shed some light on this or give an alternate solution?
Thanks!
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jan Regent
2015-10-04 14:47:07 UTC
Permalink
This works :-)


Scenario Outline: Scenario Outline example
Given I have RestAPI '<iterationNumber>'
When I read '<iterationNumber>' and '<api_key>'
Then the '<iterationNumber>' and results table
| links list |
| aaa |
| bbb |

Examples:
| iterationNumber | api_key |
| 0 | @@app.config=api_key_full |
| 1 | @@app.config=api_key_limited |


Debug this

[Given(@"I have RestAPI '(.*)'")]
public void GivenIHaveRestAPI(int iterationNumber)
{
Console.WriteLine(iterationNumber);
}

[When(@"I read '(.*)' and '(.*)'")]
public void WhenIReadAnd(int iterationNumber, string p1)
{

Console.WriteLine(iterationNumber);
}

[Then(@"the '(.*)' and results table")]
public void ThenTheAndResultsTable(int iterationNumber, Table table)
{
Console.WriteLine(iterationNumber);
}
Post by Matthew Chan
Hi Jan,
Thank you for your reply, however this doesn't work for me because I need
this to work for ALL steps and this also doesn't give me the number of
examples and iteration number.
Regards,
Matt
Post by Jan Regent
I have this solution
Scenario Outline: some title
Given I have ...
When I read ... with '<api_key>'
Then ...
| api_key |
In THEN step I have
reportHelper.Report_Pass(ScenarioContext.Current.ScenarioInfo.Title + " -
" + restHelper.Api_key);
where restHelper.Api_key is value from WHEN '<api_key>'
It gives different names scenario in the report
Enjoy JRE
Post by Matthew Chan
Hi,
I currently want to return the rows for the Examples for Scenario
Outlines and get the size of the rows, however I am unable to do this as
when SpecRun reads the feature files, it automatically converts scenario
outline examples into individual scenarios for a custom report we want to
create which requires this information.
ScenarioContext.Current.ScenarioInfo does not give me this capability.
When faced with the same issue in JAVA, we implemented gherkin.formatter
into a custom class and invoked it in the RunCukesTest class with plugins =
{"my.package.customreport"}
However I'm not sure how the same can be done in .Net SpecRun after
importing the gherkin.dll.
Could anybody please shed some light on this or give an alternate solution?
Thanks!
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ravee Bellur
2015-10-05 01:41:48 UTC
Permalink
In cucumber-jvm we can get the Examples count in scenario outline by
implementing the Formatter interface.


//The method below is called before the actual execution of the scenario
examples. This gives the count of examples in scenario outline

*public* *void* examples(Examples examples) {

int count = examples.getRows().size();

}


I am not sure how this can be implemented in Specflow. Would be interested
to know.
Post by Jan Regent
This works :-)
Scenario Outline: Scenario Outline example
Given I have RestAPI '<iterationNumber>'
When I read '<iterationNumber>' and '<api_key>'
Then the '<iterationNumber>' and results table
| links list |
| aaa |
| bbb |
| iterationNumber | api_key |
Debug this
public void GivenIHaveRestAPI(int iterationNumber)
{
Console.WriteLine(iterationNumber);
}
public void WhenIReadAnd(int iterationNumber, string p1)
{
Console.WriteLine(iterationNumber);
}
public void ThenTheAndResultsTable(int iterationNumber, Table table)
{
Console.WriteLine(iterationNumber);
}
Post by Matthew Chan
Hi Jan,
Thank you for your reply, however this doesn't work for me because I need
this to work for ALL steps and this also doesn't give me the number of
examples and iteration number.
Regards,
Matt
Post by Jan Regent
I have this solution
Scenario Outline: some title
Given I have ...
When I read ... with '<api_key>'
Then ...
| api_key |
In THEN step I have
reportHelper.Report_Pass(ScenarioContext.Current.ScenarioInfo.Title + " -
" + restHelper.Api_key);
where restHelper.Api_key is value from WHEN '<api_key>'
It gives different names scenario in the report
Enjoy JRE
Post by Matthew Chan
Hi,
I currently want to return the rows for the Examples for Scenario
Outlines and get the size of the rows, however I am unable to do this as
when SpecRun reads the feature files, it automatically converts scenario
outline examples into individual scenarios for a custom report we want to
create which requires this information.
ScenarioContext.Current.ScenarioInfo does not give me this capability.
When faced with the same issue in JAVA, we implemented
gherkin.formatter into a custom class and invoked it in the RunCukesTest
class with plugins = {"my.package.customreport"}
However I'm not sure how the same can be done in .Net SpecRun after
importing the gherkin.dll.
Could anybody please shed some light on this or give an alternate solution?
Thanks!
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Gáspár Nagy
2015-10-05 05:58:13 UTC
Permalink
Hi,

As I am currently working on the new Gherkin3 parser integration to
SpecFlow, such things will be much easier and they will be more compliant
to the solutions of other Cucumber implementations.

What works already: SpecFlow handles the first column of the examples table
in a special way. If it contains unique values, SpecFlow assumes you use it
for identifying the examples (e.g. using it as an examples title or name).
This names will be used to generate the method names for the test methods
for example. You can define examples columns without actually using them in
the scenatio outline.

Br,
Gaspar
Post by Ravee Bellur
In cucumber-jvm we can get the Examples count in scenario outline by
implementing the Formatter interface.
//The method below is called before the actual execution of the scenario
examples. This gives the count of examples in scenario outline
*public* *void* examples(Examples examples) {
int count = examples.getRows().size();
}
I am not sure how this can be implemented in Specflow. Would be interested
to know.
Post by Jan Regent
This works :-)
Scenario Outline: Scenario Outline example
Given I have RestAPI '<iterationNumber>'
When I read '<iterationNumber>' and '<api_key>'
Then the '<iterationNumber>' and results table
| links list |
| aaa |
| bbb |
| iterationNumber | api_key |
Debug this
public void GivenIHaveRestAPI(int iterationNumber)
{
Console.WriteLine(iterationNumber);
}
public void WhenIReadAnd(int iterationNumber, string p1)
{
Console.WriteLine(iterationNumber);
}
public void ThenTheAndResultsTable(int iterationNumber, Table table)
{
Console.WriteLine(iterationNumber);
}
Post by Matthew Chan
Hi Jan,
Thank you for your reply, however this doesn't work for me because I
need this to work for ALL steps and this also doesn't give me the number of
examples and iteration number.
Regards,
Matt
Post by Jan Regent
I have this solution
Scenario Outline: some title
Given I have ...
When I read ... with '<api_key>'
Then ...
| api_key |
In THEN step I have
reportHelper.Report_Pass(ScenarioContext.Current.ScenarioInfo.Title + " -
" + restHelper.Api_key);
where restHelper.Api_key is value from WHEN '<api_key>'
It gives different names scenario in the report
Enjoy JRE
Post by Matthew Chan
Hi,
I currently want to return the rows for the Examples for Scenario
Outlines and get the size of the rows, however I am unable to do this as
when SpecRun reads the feature files, it automatically converts scenario
outline examples into individual scenarios for a custom report we want to
create which requires this information.
ScenarioContext.Current.ScenarioInfo does not give me this capability.
When faced with the same issue in JAVA, we implemented
gherkin.formatter into a custom class and invoked it in the RunCukesTest
class with plugins = {"my.package.customreport"}
However I'm not sure how the same can be done in .Net SpecRun after
importing the gherkin.dll.
Could anybody please shed some light on this or give an alternate solution?
Thanks!
--

*Gaspar Nagy* ▪ coach, trainer and bdd addict

email <http://gasparnagy.com/Contact/> ▪ twitter
<http://www.twitter.com/gasparnagy> ▪ linkedin
<https://hu.linkedin.com/in/gasparnagy> ▪ blog <http://blog.gasparnagy.com/>

specflow course <http://gasparnagy.com/trainings/specflow/>: vienna
<http://bit.ly/sf201510vie> ▪ kiev <http://bit.ly/sf201511kie> ▪ oslo
<http://bit.ly/sf201602osl> ▪ in-your-office
<http://gasparnagy.com/trainings/private/>
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jan Regent
2015-10-05 10:47:25 UTC
Permalink
Thanks a lot for your work, Gaspar, thanks :-)
JRE
Post by Gáspár Nagy
Hi,
As I am currently working on the new Gherkin3 parser integration to
SpecFlow, such things will be much easier and they will be more compliant
to the solutions of other Cucumber implementations.
What works already: SpecFlow handles the first column of the examples
table in a special way. If it contains unique values, SpecFlow assumes you
use it for identifying the examples (e.g. using it as an examples title or
name). This names will be used to generate the method names for the test
methods for example. You can define examples columns without actually using
them in the scenatio outline.
Br,
Gaspar
Post by Ravee Bellur
In cucumber-jvm we can get the Examples count in scenario outline by
implementing the Formatter interface.
//The method below is called before the actual execution of the scenario
examples. This gives the count of examples in scenario outline
*public* *void* examples(Examples examples) {
int count = examples.getRows().size();
}
I am not sure how this can be implemented in Specflow. Would be
interested to know.
Post by Jan Regent
This works :-)
Scenario Outline: Scenario Outline example
Given I have RestAPI '<iterationNumber>'
When I read '<iterationNumber>' and '<api_key>'
Then the '<iterationNumber>' and results table
| links list |
| aaa |
| bbb |
| iterationNumber | api_key |
Debug this
public void GivenIHaveRestAPI(int iterationNumber)
{
Console.WriteLine(iterationNumber);
}
public void WhenIReadAnd(int iterationNumber, string p1)
{
Console.WriteLine(iterationNumber);
}
public void ThenTheAndResultsTable(int iterationNumber, Table table)
{
Console.WriteLine(iterationNumber);
}
Post by Matthew Chan
Hi Jan,
Thank you for your reply, however this doesn't work for me because I
need this to work for ALL steps and this also doesn't give me the number of
examples and iteration number.
Regards,
Matt
Post by Jan Regent
I have this solution
Scenario Outline: some title
Given I have ...
When I read ... with '<api_key>'
Then ...
| api_key |
In THEN step I have
reportHelper.Report_Pass(ScenarioContext.Current.ScenarioInfo.Title + " -
" + restHelper.Api_key);
where restHelper.Api_key is value from WHEN '<api_key>'
It gives different names scenario in the report
Enjoy JRE
Post by Matthew Chan
Hi,
I currently want to return the rows for the Examples for Scenario
Outlines and get the size of the rows, however I am unable to do this as
when SpecRun reads the feature files, it automatically converts scenario
outline examples into individual scenarios for a custom report we want to
create which requires this information.
ScenarioContext.Current.ScenarioInfo does not give me this capability.
When faced with the same issue in JAVA, we implemented
gherkin.formatter into a custom class and invoked it in the RunCukesTest
class with plugins = {"my.package.customreport"}
However I'm not sure how the same can be done in .Net SpecRun after
importing the gherkin.dll.
Could anybody please shed some light on this or give an alternate solution?
Thanks!
--
*Gaspar Nagy* ▪ coach, trainer and bdd addict
email <http://gasparnagy.com/Contact/> ▪ twitter
<http://www.twitter.com/gasparnagy> ▪ linkedin
<https://hu.linkedin.com/in/gasparnagy> ▪ blog
<http://blog.gasparnagy.com/>
specflow course <http://gasparnagy.com/trainings/specflow/>: vienna
<http://bit.ly/sf201510vie> ▪ kiev <http://bit.ly/sf201511kie> ▪ oslo
<http://bit.ly/sf201602osl> ▪ in-your-office
<http://gasparnagy.com/trainings/private/>
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthew Chan
2015-10-05 12:56:01 UTC
Permalink
Thank you for your reply Gaspar, however we are looking for a solution
similar to what we've done in Java by implementing a listener such as the
gherkin.formatter class and invoking it through the runner class under the
plugins section.

Are you able to provide any alternatives in the .Net space? I have tried
implementing the .Net gherkin-2.6.5.dll and IGherkinListener into my Hooks
class but still am not sure how to invoke it with SpecRun.

Regards,
Matt
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Matthew Chan
2015-10-05 13:00:13 UTC
Permalink
Thank you for your reply Gaspar, however we are looking for a solution
similar to what we've done in Java by implementing a listener such as the
gherkin.formatter class and invoking it through the runner class under the
plugins section.

As we are creating a custom report in JSON format to send in the AfterHooks
of each scenario, this specific information is crucial to us. The solution
we are implementing is also for existing projects so changing the Examples
table of ALL the existing Scenario Outlines in our testing suite is not
feasible.

Are you able to provide any alternatives in the .Net space? I have tried
implementing the .Net gherkin-2.6.5.dll and IGherkinListener into my Hooks
class but still am not sure how to invoke it with SpecRun.

Regards,
Matt
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Ajay Polsani
2016-03-08 08:18:58 UTC
Permalink
Hi Ravee

Could you please provide an example of how you have used the below method.

Regards
Ajay
Post by Ravee Bellur
In cucumber-jvm we can get the Examples count in scenario outline by
implementing the Formatter interface.
//The method below is called before the actual execution of the scenario
examples. This gives the count of examples in scenario outline
*public* *void* examples(Examples examples) {
int count = examples.getRows().size();
}
I am not sure how this can be implemented in Specflow. Would be interested
to know.
Post by Jan Regent
This works :-)
Scenario Outline: Scenario Outline example
Given I have RestAPI '<iterationNumber>'
When I read '<iterationNumber>' and '<api_key>'
Then the '<iterationNumber>' and results table
| links list |
| aaa |
| bbb |
| iterationNumber | api_key |
Debug this
public void GivenIHaveRestAPI(int iterationNumber)
{
Console.WriteLine(iterationNumber);
}
public void WhenIReadAnd(int iterationNumber, string p1)
{
Console.WriteLine(iterationNumber);
}
public void ThenTheAndResultsTable(int iterationNumber, Table table)
{
Console.WriteLine(iterationNumber);
}
Post by Matthew Chan
Hi Jan,
Thank you for your reply, however this doesn't work for me because I
need this to work for ALL steps and this also doesn't give me the number of
examples and iteration number.
Regards,
Matt
Post by Jan Regent
I have this solution
Scenario Outline: some title
Given I have ...
When I read ... with '<api_key>'
Then ...
| api_key |
In THEN step I have
reportHelper.Report_Pass(ScenarioContext.Current.ScenarioInfo.Title + " -
" + restHelper.Api_key);
where restHelper.Api_key is value from WHEN '<api_key>'
It gives different names scenario in the report
Enjoy JRE
Post by Matthew Chan
Hi,
I currently want to return the rows for the Examples for Scenario
Outlines and get the size of the rows, however I am unable to do this as
when SpecRun reads the feature files, it automatically converts scenario
outline examples into individual scenarios for a custom report we want to
create which requires this information.
ScenarioContext.Current.ScenarioInfo does not give me this capability.
When faced with the same issue in JAVA, we implemented
gherkin.formatter into a custom class and invoked it in the RunCukesTest
class with plugins = {"my.package.customreport"}
However I'm not sure how the same can be done in .Net SpecRun after
importing the gherkin.dll.
Could anybody please shed some light on this or give an alternate solution?
Thanks!
--
You received this message because you are subscribed to the Google Groups "SpecFlow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to specflow+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Continue reading on narkive:
Loading...