How to run a burn script several times

I wrote this gherkin function and it works great. But my company asked me to be able to run it several times during the tests. We have a client side application that controls the server side to simulate a real person using software. Therefore, my client side is created once and should run 3 times higher than this scenario.

Is there a for statement that I can use here?

Feature: Test program startup time Background: Given my program is activated with a licence Scenario: Startup Given I want to use a clean installation Given the user preferences file is user_startup_performances.config Given the CurrentPath directory is empty Given I want to monitor startup performances Then I want to log those data 

Greetings!

+4
source share
3 answers

In your current function, you write:

 Given I want to monitor start-up performances for run '<id>' 

When you use β€œI want” after β€œGiven”, you should use β€œNext” instead, because you are expecting a result.

Also the following:

 Then I want to log those data 

largely coincides with the previous one. Given that you want to get the log data.

I would rewrite your script as follows:

 Feature: Test my program startup time Background: Given the system is activated with a license And I have a clean installation environment Scenario Outline: Startup Given the system is ready to start When I perform test run '<id>' Then the system should start in less than 3 seconds And the system should generate log data for test run '<id>' Examples: Run ID | id | | 1 | | 2 | | 3 | 

Also, if the step:

 And I have a clean installation environment 

explicitly clears CurrentPath and sets the configuration file as user_startup_performance.config, then I would get rid of:

 And the user preferences file is user_startup_performances.config And the CurrentPath directory is empty 

This is what I did in my proposed rewrite.

+2
source

I am not sure this is a "test".

This is definitely a script that captures data, but tests also have a condition, value, or state in them that needs to be checked.

So, I would expect to see something more like

 Given I set something up And I setup something else .... When I run the program Then my startup time should be less than 1 second 

However, I understand your desire for a simple, consistent way to run this test, and although I believe that SpecFlow may not be the best way to achieve what you want, you can consider the granularity of your tests. For example, you can rewrite your script as

 Given I ... When I run the program Then my startup time should be less than 1 second When I run the program Then my startup time should be less than 1 second When I run the program Then my startup time should be less than 1 second 

And now you checked three times.

Or you could write it like

 Given I ... When I run the program 3 times Then my startup time should be less than 1 second 

and then in your c #

 [When("I run the program (\d+) times")] public void WhenIRunTheProgramManyTimes(int count) { for(int i=0; i++; i<count) WhenIRunTheProgram(); } [When("I run the program")] public void WhenIRunTheProgram() { .... 

Also look at Dan North. Whose domain is it anyway? , this can help you structure your future scenarios. :-)

+1
source

You are right, this is not just a test, it is one of the performance tests that we run every night to see the stability of the solution. Thus, the point is more to receive data than to see the green success button :)

If specflow is not the best solution, which tool could be better?

The software design does not allow me to use "When I run the program 3 times", unfortunately ... and I did not want to just repeat the same line 3 times.

Anyway, I used the script scheme and determined how my steps depended on the examples. Then, if someone wants to change the number of runs, all he needs to do is add a few lines to the example.

I have been looking for a loop statement as I start with these technologies. These were also not the best tasks for the first scenario :)

Thanks!

PS: here is the script

 Feature: Test my program startup time Background: Given my program is activated with a licence elite Scenario Outline: Startup Given I want to use a clean installation Given the user preferences file is user_startup_performances.config Given the CurrentPath directory is empty Given I want to monitor startup performances for run '<id>' Then I want to log those data Examples: Run ID | id | | 1 | | 2 | | 3 | 
0
source

Source: https://habr.com/ru/post/1488331/


All Articles