简体   繁体   中英

Reporting name, steps and status on Specflow tests using nunit

On my project we have decided to use specflow to convert our acceptance criterias written in gherkin syntax into "acceptance tests". Since we do not wish to spend tonnes of money on a testrunner, we have decided to use nunit instead of the expensive Specflow+ runner. Our stakeholders require that we report what acceptance criterias we have made automatic tests for and what their status are. In order to do this I was thinking that we would scrape the output of nunit to list the names of all of our tests, their steps and their status (success or failure). The problem is that even though I get all the information I need when I run the tests through Rider, when running it through the command line I can only seem to get the name of the tests and the status of the entire test and not the steps themselves nor the name of the feature that is being tested.

Does anyone know if it is possible to get this information out of the box, or do I have to write my own test runner or add BeforeScenario/AfterScenario/BeforeStep/AfterStep code to log this information myself? I have tried all the different verbosity levels that I can specify when running dotnet test, but I still do not get the information I want

Not sure about out of the box solution but this is working fine for me

 public binding(ScenarioContext scenarioContext)
        {

            _scenarioContext = scenarioContext;
        }

print name

binding._scenarioContext.StepContext.StepInfo.Text.ToString()

print status

  binding._scenarioContext.ScenarioExecutionStatus.ToString()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM