-
Notifications
You must be signed in to change notification settings - Fork 19
Getting Started
The first step is to install SpecFlow. To do that you need to add the SpecFlow extension to visual studio. After doing that you are ready to setup your solution.
When creating a new solution, select the 'Unit Test Project (.NET core)' project type. After creating, update the .net framework to net462
ImageHere
You need to install the following nuget packages:
- Vermaat.Crm.Specflow
- SpecRun.SpecFlow
- SpecFlow.Tools.MsBuild.Generation
- Selenium.WebDriver.ChromeDriver (or a webdriver for another browser you want to use)
It's possible some of the dependent packages that have been installed do not have the latest version. Feel free to update any of them (Do not update the ActiveDirectory package).
First of all you can delete the UnitTest1.cs file, because you will write SpecFlow scenarios instead.
You will need a Default.srprofile file. You can add them under the new items in the specflow tab
ImageHere
An additional setup step is setting the correct Targets and Transformation in the Default.srprofile. I recommend copy pasting the whole file from the sample project. The only element you should keep from your original file is the 'Settings' element with the projectname and projectid. You also need to manually add any additional assemblies in case you have your own assemblies for steps.
An important note is that the sample project is configured to retry for one time after a failure. If you set this to '0' and run tests from Visual Studio, the tests will disappear after a failure.
For the app.config I recommend copy pasting the appsettings, ConfigSection & Specflow sections from the sample project into your app.config.
Setting | Description |
---|---|
AppName | Name of the model driven app you will use for your tests. You can set this at runtime with using a BeforeScenario specflow hook. |
AuthType | Authentication type for the API connection |
ClientSettingsProvider.ServiceUri | Part of a nuget package, leave as is |
DateFormat | Format for Date values in your features |
TimeFormat | Format for Time values in your features |
DefaultDataFile | Name of the XML file used to supply default values |
LanguageCode | Languagecode you will use for your tests |
Target | Leave empty, this will be filled at runtime |
Url | URL to the Dynamics environment |
Username | Username for the admin connection. You can set this at runtime with using a BeforeScenario specflow hook. |
Password | Password for the admin connection. You can set this at runtime with using a BeforeScenario specflow hook. |
AsyncJobTimeoutInSeconds | Maximum amount of seconds a test waits for asynchronous process to complete |
LoginType | This specifies the way the default login works. See LoginTypes |
In the sample project you also see a reference to a file named 'appsettings.config'. This is a file that is not checked in, that contains the credentials, url and authtype. This is a simple way to make sure your credentials stay somewhat safe. It's by far a perfect solution as the credentials will still be saved plain text on your harddrive, but a nice solution for the little effort it takes.
<appSettings>
<add key="Username" value="" />
<add key="Password" value="" />
<add key="Url" value="" />
<add key="AuthType" value="" />
<add key="ClientId" value="" />
<add key="ClientSecret" value="" />
</appSettings>
This file need to exist for the test to run. You can copy paste it from the sample project and add your own data. The file can be empty. Also don't forget to set it to 'copy always' in the file's properties.
After all the above steps, you are ready to create scenarios. See the Writing Features page for more information regarding writing scenarios.