Here is a simple example for a Given-When-Then scenario expressed with C# using an internal DSL:
public class Calculator : Scenario
public void AddToCurrentTotal()
Here is the same scenario expressed using Gherkin:
Scenario: “+” should add to current total
Given the current total is “5”
When I enter “7”
And I enter “+”
Then the current total should be “12”
Internal DSLs have the advantage of being fully integrated with the general purpose tool chain, such as refactoring and editor integration. However, their usability is limited by the constraints of the underlying general purpose language.
External DSLs can be better tailored to the domain’s purpose, but their tool chain is usually less extensive than general purpose language tools.