Giter Site home page Giter Site logo

specflow-xrm-bindings's Introduction

SpecFlow for Dynamics 365

Web

Build Status

UCI

Build Status

Description

A SpecFlow bindings library for Dynamics 365. The aim of this project is to make Dynamics 365 test automation easier, faster and more accessible. It does this by providing a library of generic SpecFlow step bindings that adhere to test automation best practices. This allows effective automated tests to be written without the dependency on developers who are both proficient with Dynamics 365 and test automation.

Table of Contents

  1. Installation
  2. Usage
  3. Contributing
  4. Credits
  5. License

Installation

Follow the guidance in the Installation and Setup section in https://specflow.org/getting-started/. After installing the IDE integration and setting up your project, install the corresponding NuGet package for your implementation - depending on whether you're using the web client or UCI.

Web

PM> Install-Package Capgemini.Test.Xrm.Web

UCI

PM> Install-Package Capgemini.Test.Xrm.Uci

Note: The UCI package does not yet contain any predefined step bindings. It currently provides XrmUciStepDefiner base class that makes writing your own bindings easier as well as ensuring that they are thread-safe - meaning your tests can be ran in parallel across all supported test runners.

WebDrivers

We do not have a dependency on any specific WebDrivers. You will need to ensure that the correct WebDrivers are available in your project based on the browser that you are targetting. For example - if your configuration file is targetting Chrome - you can install the Chrome WebDriver via NuGet -

PM> Install-Package Selenium.Chrome.WebDriver

Usage

This section applies primarily to the Capgemini.Test.Xrm.Web package as do not have pre-defined step bindings available for UCI. If you are using UCI, please skip ahead to the writing step definitions section.

Configuration

Installing the NuGet package creates a spec-xrm.yaml file in your project's root. This is used to configure the URL, browser, users and apps that will be used for your tests. You also have the option to configure a remoteServerUrl if you using a remote WebDriver (e.g. Selenium Grid).

url: "https://instance.region.dynamics.com"
browser: Chrome
remoteServerUrl: "http://localhost:4444/wd/hub"
users:
  - username: "[email protected]"
    password: "Password123"
    isAdfs: false
    alias: "a salesperson"
apps:
  - id: "7d4981cd-ec11-43b3-bdcc-3cb67b092b29"
    name: "Sales App"

Writing feature files

After the NuGet package is installed, your projects app.config is transformed to include the following -

<specFlow>
  <stepAssemblies>
    <stepAssembly assembly="Capgemini.Test.Xrm.Web" />
  </stepAssemblies>
</specFlow>

This tells SpecFlow to include the step bindings defined in the Capgemini.Test.Xrm.Web.dll. You can then use the predefined step bindings to write your tests -

Scenario: Save a record with no name
	Given I am logged in as "a salesperson"
	And I have created "a demo record with no name"
	When I save the record
	Then I should see an error on the "cap_name" field which reads "You must provide a value for Name."

Writing step defintions

Both the web and UCI packages provide a way for you to write your own step bindings that have thread-safe access to EasyRepro and the WebDriver. This ensures that your tests can be ran safely in parallel. You can do this by creating a class decorated with the SpecFlow BindingAttribute and inheriting from the either the XrmWebStepDefiner or XrmUciStepDefiner base classes. You can then create your SpecFlow step bindings as normal while interacting with the Browser and Driver properties.

[Binding]
public class MyCustomSteps : XrmWebStepDefiner
{
    [Given(@"I have a custom step")]
    public void GivenIHaveACustomStep()
    {
      // Interact with the inherited EasyRepro 'Browser' object.
      // Interact with the inherited Selenium 'WebDriver' object.
    }
}

Test setup

We are avoiding performing test setup via the UI. This speeds up test execution and makes the tests more robust (as UI automation is more fragile than using supported APIs). Given steps should therefore be carried out using the Client API, WebAPI or Organization Service.

You can create test data by using the following Given step -

Given I have created "a record"

It will look for a JSON file in the Data folder. You must ensure that these files are copying to the build output directory. You do not need to include the .json extension when writing the step (the example above would look for 'a record.json').

The JSON is the same as expected by WebAPI when creating records via a deep insert. The example below will create the following -

  • An account
  • An primary contact related to the account
  • An opportunity related to the account
  • A task related to the opportunity
{
  "@logicalName": "account",
  "@alias": "sample account",
  "name": "Sample Account",
  "primarycontactid": {
    "firstname": "John",
    "lastname": "Smith"
  },
  "opportunity_customer_accounts": [
    {
      "name": "Opportunity associated to Sample Account",
      "Opportunity_Tasks": [{ "subject": "Task associated to opportunity" }]
    }
  ]
}

Contributing

The source code for will be made available soon. All contributions will be appreciated.

To contact us, please email [email protected].

Credits

Capgemini UK Microsoft Team

And the creators of the following:

License

SpecFlow for Dynamics 365 is released under the MIT license.

specflow-xrm-bindings's People

Contributors

ewingjm avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.