How do I do unit & integration testing in a BDD style in ASP.NET MVC?

后端 未结 2 2060
难免孤独
难免孤独 2021-02-08 08:11

I am learning Behavior Driven Development with ASP.NET MVC and, based on a post from Steve Sanderson, understand that BDD can mean, at least, the following test types: individua

2条回答
  •  时光取名叫无心
    2021-02-08 08:31

    I generally agree with what Jason posted.

    You might want to divide your specs into two categories, system/integration and unit-level tests. You can describe both categories with any framework, but keep in mind that code-only approaches (NUnit, MSpec, etc.) require a business analyst to be capable of writing C#. SpecFlow/Gherkin can be a better approach if you want to involve analysts and users in writing specifications. Since the syntax and rules (Given, When, Then) are easy to understand and writing specifications from a user's perspective are easy to jot down after little training. It's all about bridging the communication gap and having users helping your team form the ubiquitous language of your domain.

    I recommend having specifications support both working "outside in" and "inside out". You may start with an "outside in" SpecFlow specification written by the user/analyst/product owner and work your way from "unimplemented" towards "green" writing the actual code. The code supporting the feature is developed using TDD with a more technically oriented framework like MSpec (the "inside out" part).

    Here's a repository that use MSpec for both unit and integration tests: https://github.com/agross/duplicatefinder.

提交回复
热议问题